mirror of
https://github.com/systemd/systemd.git
synced 2026-08-04 15:10:33 +00:00
journalctl: do not add io event source for stdout if it is a file
Fixes a bug introduced by 713342d9b0.
Fixes #28636.
Fixes https://bugzilla.redhat.com/show_bug.cgi?id=2228089.
This commit is contained in:
committed by
Luca Boccassi
parent
b456f2266a
commit
f882a986c2
@@ -2310,6 +2310,7 @@ static int on_signal(sd_event_source *s, const struct signalfd_siginfo *si, void
|
||||
|
||||
static int setup_event(Context *c, int fd, sd_event **ret) {
|
||||
_cleanup_(sd_event_unrefp) sd_event *e = NULL;
|
||||
struct stat st;
|
||||
int r;
|
||||
|
||||
assert(arg_follow);
|
||||
@@ -2328,10 +2329,15 @@ static int setup_event(Context *c, int fd, sd_event **ret) {
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to add io event source for journal: %m");
|
||||
|
||||
/* Also keeps an eye on STDOUT, and exits as soon as we see a POLLHUP on that, i.e. when it is closed. */
|
||||
r = sd_event_add_io(e, NULL, STDOUT_FILENO, EPOLLHUP|EPOLLERR, NULL, INT_TO_PTR(-ECANCELED));
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to add io event source for stdout: %m");
|
||||
if (fstat(STDOUT_FILENO, &st) < 0)
|
||||
return log_error_errno(r, "Failed to stat stdout: %m");
|
||||
|
||||
if (IN_SET(st.st_mode & S_IFMT, S_IFCHR, S_IFIFO, S_IFSOCK)) {
|
||||
/* Also keeps an eye on STDOUT, and exits as soon as we see a POLLHUP on that, i.e. when it is closed. */
|
||||
r = sd_event_add_io(e, NULL, STDOUT_FILENO, EPOLLHUP|EPOLLERR, NULL, INT_TO_PTR(-ECANCELED));
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to add io event source for stdout: %m");
|
||||
}
|
||||
|
||||
if (arg_lines != 0 || arg_since_set) {
|
||||
r = sd_event_add_defer(e, NULL, on_first_event, c);
|
||||
|
||||
Reference in New Issue
Block a user