commit 364a284eb3b5e90a9ec0ea6b29be8b74d2a92fa5 (tree)
parent a26800c0992b123b1ef16712ec1e56fb62b0caf9
Author: Andrew Kelley <andrew@ziglang.org>
Date: Sun, 16 Feb 2020 21:35:12 -0500
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:
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git 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;
}