X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fbasic%2Futil.c;h=c6d3442c9fde8ca72c3af4cb22bef0c0465b7b41;hb=6b05aab633fa55aa3070f186869d8fa219be2f38;hp=b049a44854ed3000e43c92e54b384a711de6af97;hpb=13e2b6689d7729cf201e4f2ac43278f11c811bc8;p=elogind.git diff --git a/src/basic/util.c b/src/basic/util.c index b049a4485..c6d3442c9 100644 --- a/src/basic/util.c +++ b/src/basic/util.c @@ -424,13 +424,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); }