From 33eddd1958ed79401218a92902c4572b75d8fae9 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Tue, 20 Mar 2018 11:36:27 +0100 Subject: [PATCH 1/2] mxqd: Fix typo in message --- mxqd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mxqd.c b/mxqd.c index 8d98ad09..958686c0 100644 --- a/mxqd.c +++ b/mxqd.c @@ -2511,7 +2511,7 @@ int main(int argc, char *argv[]) killall_cancelled(server); killall_over_time(server); killall_over_memory(server); - mx_log_info("jobs_running=%lu global_sigint_cnt=%d global_sigterm_cnt=%d : Exiting. Wating for jobs to finish. Sleeping for a while.", + mx_log_info("jobs_running=%lu global_sigint_cnt=%d global_sigterm_cnt=%d : Exiting. Waiting for jobs to finish. Sleeping for a while.", server->jobs_running, global_sigint_cnt, global_sigterm_cnt); From 56c6fd2485962176885760e99cf06207302e22d0 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Tue, 20 Mar 2018 11:23:51 +0100 Subject: [PATCH 2/2] mxqd: Restore SIGPIPE to default for job The mysql client library sets SIGPIPE to SIG_IGN which gets inherited by the user processes: root@sigchld:~# cat /proc/27900/status |grep Sig SigQ: 0/30656 SigPnd: 0000000000000000 SigBlk: 0000000000000000 SigIgn: 0000000000001000 SigCgt: 0000000000000000 This makes a difference for things like CMD | head -1 because CMD is not killed by SIGPIPE when `head` is finished. It will get an error "broken pipe" on the next write and may or may not emit this to stderr. This bug was partially caused by #63 (commit ff2f49fa (mxqd: Use synchronous signals)), where we changed our own signal handling to synchronous mode. While in the previous mode, we unknowingly fixed the change done by the mysql library, we then just set and reset the blocking mask, which doesn't restore an ignored signal. Restore SIGCHLD to SIG_DFL when we initialize the child process for the user. With this patch applied, no more signals are blocked for the user process. buczek@theinternet:~/git/mxq (restore-sigpipe)$ cat /proc/17081/status |grep Sig SigQ: 1/127301 SigPnd: 0000000000000000 SigBlk: 0000000000000000 SigIgn: 0000000000000000 SigCgt: 0000000000000000 Fixes: https://github.molgen.mpg.de/mariux64/mxq/issues/71 --- mxqd.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mxqd.c b/mxqd.c index 958686c0..d8fd333d 100644 --- a/mxqd.c +++ b/mxqd.c @@ -719,6 +719,7 @@ static int init_child_process(struct mxq_group_list *glist, struct mxq_job *job) group = &glist->group; sigprocmask(SIG_UNBLOCK,&all_signals,NULL); + signal(SIGPIPE,SIG_DFL); passwd = getpwuid(group->user_uid); if (!passwd) {