diff options
author | Lennart Poettering <lennart@poettering.net> | 2021-11-02 15:50:55 +0100 |
---|---|---|
committer | Luca Boccassi <luca.boccassi@gmail.com> | 2021-11-03 23:05:26 +0000 |
commit | aedec452b9e5dd197881f2164fb205dfe8bfdcec (patch) | |
tree | 551d116509319e98aa5f4a6e4f792a95af7c38bf /src/journal-remote | |
parent | 829b86bc0fa2b6bf68ee90b33b0382b71f96f6f6 (diff) | |
download | systemd-aedec452b9e5dd197881f2164fb205dfe8bfdcec.tar.gz |
tree-wide: always use TAKE_FD() when calling rearrange_stdio()
rearrange_stdio() invalidates specified fds even on failure, which means
we should always invalidate the fds we pass in no matter what. Let's
make this explicit by using TAKE_FD() for that everywhere.
Note that in many places we such invalidation doesnt get us much
behaviour-wise, since we don't use the variables anymore later. But
TAKE_FD() in a way is also documentation, it encodes explicitly that the
fds are invalidated here, so I think it's a good thing to always make
this explicit here.
Diffstat (limited to 'src/journal-remote')
-rw-r--r-- | src/journal-remote/journal-remote-main.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/journal-remote/journal-remote-main.c b/src/journal-remote/journal-remote-main.c index 91b28d0410..67f1267d0a 100644 --- a/src/journal-remote/journal-remote-main.c +++ b/src/journal-remote/journal-remote-main.c @@ -83,9 +83,9 @@ static int spawn_child(const char* child, char** argv) { /* In the child */ if (r == 0) { - safe_close(fd[0]); + fd[0] = safe_close(fd[0]); - r = rearrange_stdio(STDIN_FILENO, fd[1], STDERR_FILENO); + 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); |