chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
c6ec3ad
)
basic/util: check return value of dup2 in fork_agent()
author
Zbigniew Jędrzejewski-Szmek
<zbyszek@in.waw.pl>
Sat, 9 Apr 2016 01:08:29 +0000
(21:08 -0400)
committer
Sven Eden
<yamakuzure@gmx.net>
Fri, 16 Jun 2017 08:12:57 +0000
(10:12 +0200)
CID #
1304689
.
src/basic/util.c
patch
|
blob
|
history
diff --git
a/src/basic/util.c
b/src/basic/util.c
index b049a44854ed3000e43c92e54b384a711de6af97..c6d3442c9fde8ca72c3af4cb22bef0c0465b7b41 100644
(file)
--- 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);
}