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
This commit is contained in:
Andrew Kelley 2020-02-16 21:35:12 -05:00
parent a26800c099
commit 364a284eb3
No known key found for this signature in database
GPG Key ID: 7C5F548F728501A9

View File

@ -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;
}