www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21649] New: Make D runtime ignore or handle SIGPIPE or

https://issues.dlang.org/show_bug.cgi?id=21649

          Issue ID: 21649
           Summary: Make D runtime ignore or handle SIGPIPE or document
                    the behavior
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: druntime
          Assignee: nobody puremagic.com
          Reporter: kdevel vogtner.de

Created attachment 1819
  --> https://issues.dlang.org/attachment.cgi?id=1819&action=edit
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>

--
Feb 19