diff options
author | Lennart Poettering <lennart@poettering.net> | 2018-02-28 23:32:49 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2018-03-02 11:42:10 +0100 |
commit | 2b33ab0957f453a06b58e4bee482f2c2d4e100c1 (patch) | |
tree | 2e69f5eba365053b6048e3780ca44fd5f92f1ddf /src/journal/cat.c | |
parent | terminal-util: port some generic code over to rearrange_stdio() (diff) | |
download | systemd-2b33ab0957f453a06b58e4bee482f2c2d4e100c1.tar.xz systemd-2b33ab0957f453a06b58e4bee482f2c2d4e100c1.zip |
tree-wide: port various places over to use new rearrange_stdio()
Diffstat (limited to 'src/journal/cat.c')
-rw-r--r-- | src/journal/cat.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/journal/cat.c b/src/journal/cat.c index c87a149a4c..1815d58158 100644 --- a/src/journal/cat.c +++ b/src/journal/cat.c @@ -135,14 +135,13 @@ int main(int argc, char *argv[]) { saved_stderr = fcntl(STDERR_FILENO, F_DUPFD_CLOEXEC, 3); - if (dup3(fd, STDOUT_FILENO, 0) < 0 || - dup3(fd, STDERR_FILENO, 0) < 0) { - r = log_error_errno(errno, "Failed to duplicate fd: %m"); + r = rearrange_stdio(STDIN_FILENO, fd, fd); /* Invalidates fd on succcess + error! */ + fd = -1; + if (r < 0) { + log_error_errno(r, "Failed to rearrange stdout/stderr: %m"); goto finish; } - fd = safe_close_above_stdio(fd); - if (argc <= optind) (void) execl("/bin/cat", "/bin/cat", NULL); else |