tree-wide: use FORK_REARRANGE_STDIO and FORK_CLOSE_ALL_FDS

This commit is contained in:
Yu Watanabe
2023-02-21 07:39:18 +09:00
parent 911f8f0183
commit 0c2aedb451
11 changed files with 51 additions and 108 deletions
+3 -8
View File
@@ -995,9 +995,9 @@ int bus_socket_exec(sd_bus *b) {
return -errno;
r = safe_fork_full("(sd-busexec)",
NULL,
s+1, 1,
FORK_RESET_SIGNALS|FORK_CLOSE_ALL_FDS|FORK_RLIMIT_NOFILE_SAFE, &b->busexec_pid);
(int[]) { s[1], s[1], STDERR_FILENO },
NULL, 0,
FORK_RESET_SIGNALS|FORK_CLOSE_ALL_FDS|FORK_REARRANGE_STDIO|FORK_RLIMIT_NOFILE_SAFE, &b->busexec_pid);
if (r < 0) {
safe_close_pair(s);
return r;
@@ -1005,11 +1005,6 @@ int bus_socket_exec(sd_bus *b) {
if (r == 0) {
/* Child */
r = rearrange_stdio(s[1], s[1], STDERR_FILENO);
TAKE_FD(s[1]);
if (r < 0)
_exit(EXIT_FAILURE);
if (b->exec_argv)
execvp(b->exec_path, b->exec_argv);
else