File tree Expand file tree Collapse file tree 1 file changed +18
-4
lines changed Expand file tree Collapse file tree 1 file changed +18
-4
lines changed Original file line number Diff line number Diff line change 26
26
27
27
#include <signal.h>
28
28
#include <assert.h>
29
+ #include <errno.h>
29
30
30
31
/****************************************************************************
31
32
* Public Functions
@@ -98,9 +99,14 @@ _sa_handler_t sigset(int signo, _sa_handler_t func)
98
99
{
99
100
_sa_handler_t disposition ;
100
101
sigset_t set ;
101
- int ret ;
102
+ int ret = - EINVAL ;
102
103
103
- DEBUGASSERT (GOOD_SIGNO (signo ) && func != SIG_ERR );
104
+ if (signo == SIGKILL || signo == SIGSTOP || !GOOD_SIGNO (signo ))
105
+ {
106
+ goto err ;
107
+ }
108
+
109
+ DEBUGASSERT (func != SIG_ERR );
104
110
105
111
sigemptyset (& set );
106
112
sigaddset (& set , signo );
@@ -110,7 +116,12 @@ _sa_handler_t sigset(int signo, _sa_handler_t func)
110
116
if (func == SIG_HOLD )
111
117
{
112
118
ret = sigprocmask (SIG_BLOCK , & set , NULL );
113
- disposition = ret < 0 ? SIG_ERR : SIG_HOLD ;
119
+ if (ret < 0 )
120
+ {
121
+ goto err ;
122
+ }
123
+
124
+ disposition = SIG_HOLD ;
114
125
}
115
126
116
127
/* No.. then signal can handle the other cases */
@@ -132,10 +143,13 @@ _sa_handler_t sigset(int signo, _sa_handler_t func)
132
143
*/
133
144
134
145
signal (signo , disposition );
135
- disposition = SIG_ERR ;
146
+ goto err ;
136
147
}
137
148
}
138
149
}
139
150
140
151
return disposition ;
152
+ err :
153
+ set_errno (- ret );
154
+ return (_sa_handler_t )SIG_ERR ;
141
155
}
You can’t perform that action at this time.
0 commit comments