diff options
author | 2017-12-24 00:54:40 +0100 | |
---|---|---|
committer | 2018-01-11 10:19:18 +0100 | |
commit | 8db0325197f7deb50ec2962f095a946263556960 (patch) | |
tree | bc4ef4c6fbde619b7f08ae78734b2c5cc2738e5e | |
parent | fd-util: use close_nointr() return value instead of errno (diff) | |
download | systemd-8db0325197f7deb50ec2962f095a946263556960.tar.gz systemd-8db0325197f7deb50ec2962f095a946263556960.tar.bz2 systemd-8db0325197f7deb50ec2962f095a946263556960.zip |
terminal-util: open /dev/null with O_CLOEXEC in make_stdio_null()
Ultimately, O_CLOEXEC should be off in fd 0, 1, 2, but when we open
/dev/null here it's unlikely to be < 0, and after dupping the fd to 0,
1, 2 we turn off O_CLOEXEC explicitly anyway.
Unless we know that what we are about to open will return 0, 1 or 2 we
should always set O_CLOEXEC in order to be safe to other threads forking
of subprocesses at the wrong moment.
(cherry picked from commit d8caff6db672ab0f2d8064c61f5ef0e8e8d288ca)
-rw-r--r-- | src/basic/terminal-util.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/basic/terminal-util.c b/src/basic/terminal-util.c index 48ee799ad..0097a8961 100644 --- a/src/basic/terminal-util.c +++ b/src/basic/terminal-util.c @@ -899,7 +899,7 @@ int make_stdio(int fd) { int make_null_stdio(void) { int null_fd; - null_fd = open("/dev/null", O_RDWR|O_NOCTTY); + null_fd = open("/dev/null", O_RDWR|O_NOCTTY|O_CLOEXEC); if (null_fd < 0) return -errno; |