Merge pull request #8314 from poettering/rearrange-stdio

refactor how we rearrange fds for stdin/stdout/stderr
This commit is contained in:
Lennart Poettering
2018-03-02 15:42:03 +01:00
committed by GitHub
18 changed files with 236 additions and 216 deletions
+2 -2
View File
@@ -2646,7 +2646,7 @@ _public_ int sd_bus_message_append_array_memfd(
if (r < 0)
return r;
copy_fd = dup(memfd);
copy_fd = fcntl(memfd, F_DUPFD_CLOEXEC, 3);
if (copy_fd < 0)
return copy_fd;
@@ -2721,7 +2721,7 @@ _public_ int sd_bus_message_append_string_memfd(
if (r < 0)
return r;
copy_fd = dup(memfd);
copy_fd = fcntl(memfd, FD_CLOEXEC, 3);
if (copy_fd < 0)
return copy_fd;
+3 -6
View File
@@ -960,14 +960,11 @@ int bus_socket_exec(sd_bus *b) {
if (r == 0) {
/* Child */
assert_se(dup3(s[1], STDIN_FILENO, 0) == STDIN_FILENO);
assert_se(dup3(s[1], STDOUT_FILENO, 0) == STDOUT_FILENO);
safe_close(s[0]);
if (!IN_SET(s[1], STDIN_FILENO, STDOUT_FILENO))
safe_close(s[1]);
if (rearrange_stdio(s[1], s[1], STDERR_FILENO) < 0)
_exit(EXIT_FAILURE);
(void) fd_cloexec(STDIN_FILENO, false);
(void) fd_cloexec(STDOUT_FILENO, false);
(void) fd_nonblock(STDIN_FILENO, false);
(void) fd_nonblock(STDOUT_FILENO, false);