@@ -152,8 +152,22 @@ static void socket_cleanup(struct su_context *ctx)
152
152
static void kill_child (pid_t pid )
153
153
{
154
154
LOGD ("killing child %d" , pid );
155
- if (pid && kill (pid , SIGKILL ))
156
- PLOGE ("kill (%d)" , pid );
155
+ if (pid ) {
156
+ sigset_t set , old ;
157
+
158
+ sigemptyset (& set );
159
+ sigaddset (& set , SIGCHLD );
160
+ if (sigprocmask (SIG_BLOCK , & set , & old )) {
161
+ PLOGE ("sigprocmask(SIG_BLOCK)" );
162
+ return ;
163
+ }
164
+ if (kill (pid , SIGKILL ))
165
+ PLOGE ("kill (%d)" , pid );
166
+ else if (sigsuspend (& old ) && errno != EINTR )
167
+ PLOGE ("sigsuspend" );
168
+ if (sigprocmask (SIG_SETMASK , & old , NULL ))
169
+ PLOGE ("sigprocmask(SIG_BLOCK)" );
170
+ }
157
171
}
158
172
159
173
static void child_cleanup (struct su_context * ctx )
@@ -172,10 +186,14 @@ static void child_cleanup(struct su_context *ctx)
172
186
exit (EXIT_FAILURE );
173
187
}
174
188
if (WIFEXITED (rc ) && WEXITSTATUS (rc )) {
175
- LOGE ("child %d terminated with error %d" , pid , rc );
189
+ LOGE ("child %d terminated with error %d" , pid , WEXITSTATUS (rc ));
190
+ exit (EXIT_FAILURE );
191
+ }
192
+ if (WIFSIGNALED (rc ) && WTERMSIG (rc ) != SIGKILL ) {
193
+ LOGE ("child %d terminated with signal %d" , pid , WTERMSIG (rc ));
176
194
exit (EXIT_FAILURE );
177
195
}
178
- LOGE ("child %d terminated, status %d" , pid , rc );
196
+ LOGD ("child %d terminated, status %d" , pid , rc );
179
197
180
198
if (ctx )
181
199
ctx -> child = 0 ;
0 commit comments