diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2020-02-16 21:35:12 -0500 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2020-02-16 21:35:12 -0500 |
| commit | 364a284eb3b5e90a9ec0ea6b29be8b74d2a92fa5 (patch) | |
| tree | 3b517217c83a56459165bb7d806ce0f891d8640d /src/os.cpp | |
| parent | a26800c0992b123b1ef16712ec1e56fb62b0caf9 (diff) | |
| download | zig-364a284eb3b5e90a9ec0ea6b29be8b74d2a92fa5.tar.gz zig-364a284eb3b5e90a9ec0ea6b29be8b74d2a92fa5.zip | |
stage1 os: handle errors from read/write
not sure why the CI is complaining about these now and not in master
branch. but this is a slight code improvement anyway
Diffstat (limited to 'src/os.cpp')
| -rw-r--r-- | src/os.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/os.cpp b/src/os.cpp index 1df0cd8e80..65e1b79524 100644 --- a/src/os.cpp +++ b/src/os.cpp @@ -826,7 +826,9 @@ static Error os_exec_process_posix(ZigList<const char *> &args, if (errno == ENOENT) { report_err = ErrorFileNotFound; } - write(err_pipe[1], &report_err, sizeof(Error)); + if (write(err_pipe[1], &report_err, sizeof(Error)) == -1) { + zig_panic("write failed"); + } exit(1); } else { // parent @@ -851,9 +853,13 @@ static Error os_exec_process_posix(ZigList<const char *> &args, if (err2) return err2; Error child_err = ErrorNone; - write(err_pipe[1], &child_err, sizeof(Error)); + if (write(err_pipe[1], &child_err, sizeof(Error)) == -1) { + zig_panic("write failed"); + } close(err_pipe[1]); - read(err_pipe[0], &child_err, sizeof(Error)); + if (read(err_pipe[0], &child_err, sizeof(Error)) == -1) { + zig_panic("write failed"); + } close(err_pipe[0]); return child_err; } |
