diff options
author | Martin Pitt <martin.pitt@ubuntu.com> | 2016-04-11 11:19:27 +0200 |
---|---|---|
committer | Martin Pitt <martin.pitt@ubuntu.com> | 2016-04-11 11:19:27 +0200 |
commit | 14b662590144571985897855f9973f16e386e0ce (patch) | |
tree | 1bd53b773f592dc583aff4635537a10a6f89fcaa /src/basic | |
parent | cbe22206143a04f573e5cfbc8c839ddf2fd8c5dc (diff) | |
parent | 7236ce6e9e379948217c31f38b48de6448521162 (diff) |
Merge pull request #2996 from keszybz/coverity-fixes
Coverity fixes
Diffstat (limited to 'src/basic')
-rw-r--r-- | src/basic/util.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/basic/util.c b/src/basic/util.c index ea1bed7ceb..f1e3bd5b48 100644 --- a/src/basic/util.c +++ b/src/basic/util.c @@ -419,13 +419,17 @@ int fork_agent(pid_t *pid, const int except[], unsigned n_except, const char *pa _exit(EXIT_FAILURE); } - if (!stdout_is_tty) - dup2(fd, STDOUT_FILENO); + if (!stdout_is_tty && dup2(fd, STDOUT_FILENO) < 0) { + log_error_errno(errno, "Failed to dup2 /dev/tty: %m"); + _exit(EXIT_FAILURE); + } - if (!stderr_is_tty) - dup2(fd, STDERR_FILENO); + if (!stderr_is_tty && dup2(fd, STDERR_FILENO) < 0) { + log_error_errno(errno, "Failed to dup2 /dev/tty: %m"); + _exit(EXIT_FAILURE); + } - if (fd > 2) + if (fd > STDERR_FILENO) close(fd); } |