summaryrefslogtreecommitdiffstats
path: root/src/journal/cat.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/journal/cat.c')
-rw-r--r--src/journal/cat.c9
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