Skip to content

mxqd starts user processes with SIGPIPE ignored #71

Closed
donald opened this issue Mar 19, 2018 · 0 comments · Fixed by #72
Closed

mxqd starts user processes with SIGPIPE ignored #71

donald opened this issue Mar 19, 2018 · 0 comments · Fixed by #72

Comments

@donald
Copy link
Contributor

donald commented Mar 19, 2018

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.

donald added a commit that referenced this issue Mar 20, 2018
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
@donald donald mentioned this issue Mar 20, 2018
pmenzel pushed a commit that referenced this issue Mar 20, 2018
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 ff2f49f (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: #71
donald added a commit to mariux64/bee-files that referenced this issue Mar 21, 2018
Includes pull request mariux64/mxq#72 for issue mariux64/mxq#71
"mxqd starts user processes with SIGPIPE ignored"
Sign in to join this conversation on GitHub.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant