aboutsummaryrefslogtreecommitdiff
path: root/test/standalone/sigpipe/breakpipe.zig
blob: 51f667fc15dd634fba5c3d13ddb3d1125f87c43e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
const std = @import("std");
const build_options = @import("build_options");

pub const std_options: std.Options = .{
    .keep_sigpipe = build_options.keep_sigpipe,
};

pub fn main() !void {
    const pipe = try std.posix.pipe();
    std.posix.close(pipe[0]);
    _ = std.posix.write(pipe[1], "a") catch |err| switch (err) {
        error.BrokenPipe => {
            try std.fs.File.stdout().writeAll("BrokenPipe\n");
            std.posix.exit(123);
        },
        else => |e| return e,
    };
    unreachable;
}