diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2018-02-06 18:12:36 -0500 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2018-02-06 18:12:36 -0500 |
commit | 649d85b8e3bd3797baa68c405d33c5241f3fb70b (patch) | |
tree | 2b8c5682b9ede0bc73d11e02094a82a7f3dbbf5d | |
parent | da29de792b5c0604c91bc8eda0c15078c8ab8501 (diff) | |
download | bfs-649d85b8e3bd3797baa68c405d33c5241f3fb70b.tar.xz |
exec: Avoid a warning when building with _FORTIFY_SOURCE
Also, don't pass the address of errno itself to write(), since write()
is allowed to modify it.
-rw-r--r-- | exec.c | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -382,8 +382,13 @@ static int bfs_exec_spawn(const struct bfs_exec *execbuf) { } execvp(execbuf->argv[0], execbuf->argv); + + int error; child_err: - write(pipefd[1], &errno, sizeof(errno)); + error = errno; + if (write(pipefd[1], &error, sizeof(error)) != sizeof(error)) { + // Parent will still see that we exited unsuccessfully, but won't know why + } close(pipefd[1]); _Exit(EXIT_FAILURE); } |