##// END OF EJS Templates
chg: forward job control signals to worker process (issue5051)...
Yuya Nishihara -
r28086:65d24ca3 default
parent child Browse files
Show More
@@ -231,6 +231,38 b' static void forwardsignal(int sig)'
231 debugmsg("forward signal %d", sig);
231 debugmsg("forward signal %d", sig);
232 }
232 }
233
233
234 static void handlestopsignal(int sig)
235 {
236 sigset_t unblockset, oldset;
237 struct sigaction sa, oldsa;
238 if (sigemptyset(&unblockset) < 0)
239 goto error;
240 if (sigaddset(&unblockset, sig) < 0)
241 goto error;
242 memset(&sa, 0, sizeof(sa));
243 sa.sa_handler = SIG_DFL;
244 sa.sa_flags = SA_RESTART;
245 if (sigemptyset(&sa.sa_mask) < 0)
246 goto error;
247
248 forwardsignal(sig);
249 if (raise(sig) < 0) /* resend to self */
250 goto error;
251 if (sigaction(sig, &sa, &oldsa) < 0)
252 goto error;
253 if (sigprocmask(SIG_UNBLOCK, &unblockset, &oldset) < 0)
254 goto error;
255 /* resent signal will be handled before sigprocmask() returns */
256 if (sigprocmask(SIG_SETMASK, &oldset, NULL) < 0)
257 goto error;
258 if (sigaction(sig, &oldsa, NULL) < 0)
259 goto error;
260 return;
261
262 error:
263 abortmsg("failed to handle stop signal (errno = %d)", errno);
264 }
265
234 static void setupsignalhandler(pid_t pid)
266 static void setupsignalhandler(pid_t pid)
235 {
267 {
236 if (pid <= 0)
268 if (pid <= 0)
@@ -253,6 +285,17 b' static void setupsignalhandler(pid_t pid'
253 sa.sa_flags |= SA_RESETHAND;
285 sa.sa_flags |= SA_RESETHAND;
254 if (sigaction(SIGTERM, &sa, NULL) < 0)
286 if (sigaction(SIGTERM, &sa, NULL) < 0)
255 goto error;
287 goto error;
288
289 /* propagate job control requests to worker */
290 sa.sa_handler = forwardsignal;
291 sa.sa_flags = SA_RESTART;
292 if (sigaction(SIGCONT, &sa, NULL) < 0)
293 goto error;
294 sa.sa_handler = handlestopsignal;
295 sa.sa_flags = SA_RESTART;
296 if (sigaction(SIGTSTP, &sa, NULL) < 0)
297 goto error;
298
256 return;
299 return;
257
300
258 error:
301 error:
General Comments 0
You need to be logged in to leave comments. Login now