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
+4 -6
View File
@@ -583,14 +583,12 @@ static int find_libraries(const char *exec, char ***ret) {
assert_se(pipe2(outpipe, O_NONBLOCK|O_CLOEXEC) == 0);
assert_se(pipe2(errpipe, O_NONBLOCK|O_CLOEXEC) == 0);
r = safe_fork("(spawn-ldd)", FORK_RESET_SIGNALS|FORK_DEATHSIG|FORK_LOG, &pid);
r = safe_fork_full("(spawn-ldd)",
(int[]) { -EBADF, outpipe[1], errpipe[1] },
NULL, 0,
FORK_RESET_SIGNALS|FORK_CLOSE_ALL_FDS|FORK_DEATHSIG|FORK_REARRANGE_STDIO|FORK_LOG, &pid);
assert_se(r >= 0);
if (r == 0) {
if (rearrange_stdio(-EBADF, TAKE_FD(outpipe[1]), TAKE_FD(errpipe[1])) < 0)
_exit(EXIT_FAILURE);
(void) close_all_fds(NULL, 0);
execlp("ldd", "ldd", exec, NULL);
_exit(EXIT_FAILURE);
}