From 364a284eb3b5e90a9ec0ea6b29be8b74d2a92fa5 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sun, 16 Feb 2020 21:35:12 -0500 Subject: [PATCH] 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 --- src/os.cpp | 12 +++++++++--- 1 file 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 &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 &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; }