diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2023-02-19 13:55:12 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-02-19 13:55:12 -0500 |
| commit | adfc019d6070cf322048bdb36d991354711c4636 (patch) | |
| tree | 1c13de6e54ee6852c566087e242e6e1f732478ca /lib/std/std.zig | |
| parent | f10950526ea781ee2d15df74398527420cca13a1 (diff) | |
| parent | dafefe9c9d3ffd484915ead0474c7e772f1dfcfb (diff) | |
| download | zig-adfc019d6070cf322048bdb36d991354711c4636.tar.gz zig-adfc019d6070cf322048bdb36d991354711c4636.zip | |
Merge pull request #11982 from marler8997/ignoreSigpipe
ignore SIGPIPE by default
Diffstat (limited to 'lib/std/std.zig')
| -rw-r--r-- | lib/std/std.zig | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/std/std.zig b/lib/std/std.zig index e02be2ebaf..5b0963ba20 100644 --- a/lib/std/std.zig +++ b/lib/std/std.zig @@ -167,6 +167,22 @@ pub const options = struct { options_override.crypto_always_getrandom else false; + + /// By default Zig disables SIGPIPE by setting a "no-op" handler for it. Set this option + /// to `true` to prevent that. + /// + /// Note that we use a "no-op" handler instead of SIG_IGN because it will not be inherited by + /// any child process. + /// + /// SIGPIPE is triggered when a process attempts to write to a broken pipe. By default, SIGPIPE + /// will terminate the process instead of exiting. It doesn't trigger the panic handler so in many + /// cases it's unclear why the process was terminated. By capturing SIGPIPE instead, functions that + /// write to broken pipes will return the EPIPE error (error.BrokenPipe) and the program can handle + /// it like any other error. + pub const keep_sigpipe: bool = if (@hasDecl(options_override, "keep_sigpipe")) + options_override.keep_sigpipe + else + false; }; // This forces the start.zig file to be imported, and the comptime logic inside that |
