summaryrefslogtreecommitdiffstats
path: root/exec.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2018-02-06 18:12:36 -0500
committerTavian Barnes <tavianator@tavianator.com>2018-02-06 18:12:36 -0500
commit649d85b8e3bd3797baa68c405d33c5241f3fb70b (patch)
tree2b8c5682b9ede0bc73d11e02094a82a7f3dbbf5d /exec.c
parentda29de792b5c0604c91bc8eda0c15078c8ab8501 (diff)
downloadbfs-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.
Diffstat (limited to 'exec.c')
-rw-r--r--exec.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/exec.c b/exec.c
index 489953e..3fa5789 100644
--- a/exec.c
+++ b/exec.c
@@ -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);
}