summaryrefslogtreecommitdiff
path: root/src/basic
diff options
context:
space:
mode:
Diffstat (limited to 'src/basic')
-rw-r--r--src/basic/fd-util.c6
-rw-r--r--src/basic/fd-util.h1
-rw-r--r--src/basic/terminal-util.c4
3 files changed, 8 insertions, 3 deletions
diff --git a/src/basic/fd-util.c b/src/basic/fd-util.c
index 8b466cff15..5c820332a5 100644
--- a/src/basic/fd-util.c
+++ b/src/basic/fd-util.c
@@ -186,6 +186,12 @@ int fd_cloexec(int fd, bool cloexec) {
return 0;
}
+void stdio_unset_cloexec(void) {
+ fd_cloexec(STDIN_FILENO, false);
+ fd_cloexec(STDOUT_FILENO, false);
+ fd_cloexec(STDERR_FILENO, false);
+}
+
_pure_ static bool fd_in_set(int fd, const int fdset[], unsigned n_fdset) {
unsigned i;
diff --git a/src/basic/fd-util.h b/src/basic/fd-util.h
index b86e41698a..34b98d4aec 100644
--- a/src/basic/fd-util.h
+++ b/src/basic/fd-util.h
@@ -63,6 +63,7 @@ DEFINE_TRIVIAL_CLEANUP_FUNC(DIR*, closedir);
int fd_nonblock(int fd, bool nonblock);
int fd_cloexec(int fd, bool cloexec);
+void stdio_unset_cloexec(void);
int close_all_fds(const int except[], unsigned n_except);
diff --git a/src/basic/terminal-util.c b/src/basic/terminal-util.c
index d8cca55378..df56d85317 100644
--- a/src/basic/terminal-util.c
+++ b/src/basic/terminal-util.c
@@ -888,9 +888,7 @@ int make_stdio(int fd) {
/* Explicitly unset O_CLOEXEC, since if fd was < 3, then
* dup2() was a NOP and the bit hence possibly set. */
- fd_cloexec(STDIN_FILENO, false);
- fd_cloexec(STDOUT_FILENO, false);
- fd_cloexec(STDERR_FILENO, false);
+ stdio_unset_cloexec();
return 0;
}