From fc76667077c0b6f769501d1bb25b1b41d5c38bf5 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Mon, 10 Sep 2018 20:33:01 -0400 Subject: exec: More fixes for bfs_exec_debug() changing errno --- exec.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'exec.c') diff --git a/exec.c b/exec.c index 43ffad0..87bb5e6 100644 --- a/exec.c +++ b/exec.c @@ -368,12 +368,12 @@ static int bfs_exec_spawn(const struct bfs_exec *execbuf) { return -1; } - errno = 0; + int ret = -1; if (WIFEXITED(wstatus)) { int status = WEXITSTATUS(wstatus); if (status == EXIT_SUCCESS) { - return 0; + ret = 0; } else { bfs_exec_debug(execbuf, "Command '%s' failed with status %d\n", execbuf->argv[0], status); } @@ -384,7 +384,8 @@ static int bfs_exec_spawn(const struct bfs_exec *execbuf) { bfs_exec_debug(execbuf, "Command '%s' terminated abnormally\n", execbuf->argv[0]); } - return -1; + errno = 0; + return ret; } else { // Child close(pipefd[0]); -- cgit v1.2.3