diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2023-02-07 10:55:39 +0100 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2023-02-20 23:39:18 +0100 |
commit | 0c2aedb451c9da0d997e46c84d399c80d7fcb61d (patch) | |
tree | 594f8797a9bf7786406c3c0af349a8c6dca4f333 /src/journal-remote/journal-remote-main.c | |
parent | process-util: rename FORK_NULL_STDIO -> FORK_REARRANGE_STDIO (diff) | |
download | systemd-0c2aedb451c9da0d997e46c84d399c80d7fcb61d.tar.xz systemd-0c2aedb451c9da0d997e46c84d399c80d7fcb61d.zip |
tree-wide: use FORK_REARRANGE_STDIO and FORK_CLOSE_ALL_FDS
Diffstat (limited to 'src/journal-remote/journal-remote-main.c')
-rw-r--r-- | src/journal-remote/journal-remote-main.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/src/journal-remote/journal-remote-main.c b/src/journal-remote/journal-remote-main.c index 7df264fb53..e620b60a31 100644 --- a/src/journal-remote/journal-remote-main.c +++ b/src/journal-remote/journal-remote-main.c @@ -85,7 +85,10 @@ static int spawn_child(const char* child, char** argv) { if (pipe(fd) < 0) return log_error_errno(errno, "Failed to create pager pipe: %m"); - r = safe_fork("(remote)", FORK_RESET_SIGNALS|FORK_DEATHSIG|FORK_LOG|FORK_RLIMIT_NOFILE_SAFE, &child_pid); + r = safe_fork_full("(remote)", + (int[]) {STDIN_FILENO, fd[1], STDERR_FILENO }, + NULL, 0, + FORK_RESET_SIGNALS|FORK_CLOSE_ALL_FDS|FORK_DEATHSIG|FORK_REARRANGE_STDIO|FORK_LOG|FORK_RLIMIT_NOFILE_SAFE, &child_pid); if (r < 0) { safe_close_pair(fd); return r; @@ -93,14 +96,6 @@ static int spawn_child(const char* child, char** argv) { /* In the child */ if (r == 0) { - fd[0] = safe_close(fd[0]); - - r = rearrange_stdio(STDIN_FILENO, TAKE_FD(fd[1]), STDERR_FILENO); - if (r < 0) { - log_error_errno(r, "Failed to dup pipe to stdout: %m"); - _exit(EXIT_FAILURE); - } - execvp(child, argv); log_error_errno(errno, "Failed to exec child %s: %m", child); _exit(EXIT_FAILURE); |