Skip to content

Commit

Permalink
mxqd: Restore SIGPIPE to default for job
Browse files Browse the repository at this point in the history
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 war partially caused by #63, 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 #71
  • Loading branch information
donald committed Mar 20, 2018
1 parent 33eddd1 commit b026af3
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions mxqd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit b026af3

Please sign in to comment.