Bug 21649 – Make D runtime ignore or handle SIGPIPE or document the behavior

Status
RESOLVED
Resolution
WONTFIX
Severity
normal
Priority
P1
Component
druntime
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2021-02-19T12:14:55Z
Last change time
2021-02-19T20:42:00Z
Assigned to
No Owner
Creator
kdevel

Attachments

IDFilenameSummaryContent-TypeSize
1819sigpipe.dreproducer, -i to ignore SIGPIPEtext/x-dsrc624

Comments

Comment #0 by kdevel — 2021-02-19T12:14:55Z
Created attachment 1819 reproducer, -i to ignore SIGPIPE Writing to a pipe may fail in case of a missing reader. The OS may then send the writing process a SIGPIPE signal which terminates the process silently (symptom: no output, exit code 141 [1]). STR (all in BASH on Linux) 1. $ dmd sigpipe 2. $ for i in {1..100}; do echo $i; ./sigpipe || echo "*** FAIL rc=$? ***"; done Found: About 10 % *** FAIL rc=141 *** Expected: About 10 % caught: Enforcement failed (Broken pipe) (re-run the sigpipe with -i argument) Maybe related to issue 1491. Ideally signal (SIGPIPE, SIG_IGN); would be called before running main. [1] <http://www.google.com/search?q=exit+code+141>
Comment #1 by schveiguy — 2021-02-19T16:55:44Z
I would suggest this be resolved as WONTFIX As I said in the forums, ignoring SIGPIPE is a process-wide setting, not suitable for all environments, so D should not be doing this to intialize the runtime. 2 examples come to mind: - starting a child process will inherit the signal ignoring, which means you alter the default behavior of those processes (which may depend on SIGPIPE being triggered) - Other libraries might depend on SIGPIPE not being ignored. I think the correct mechanism is to manually ignore the signal on program startup if that is your preference.
Comment #2 by dlang-bugzilla — 2021-02-19T20:36:46Z
std.socket uses the MSG_NOSIGNAL flag with send to prevent SIGPIPE.
Comment #3 by dlang-bugzilla — 2021-02-19T20:42:00Z
I agree with Steven's assessment.