diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2022-11-24 01:42:48 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-24 01:42:48 +0100 |
commit | 00a60eaf5fcb3a0e415349aa649f2699550d26b0 (patch) | |
tree | 211135dfa606bf397a61c1a20db4a9d4b033f6d8 /src/shared/utmp-wtmp.c | |
parent | core: add possibility to not track certain unit types (diff) | |
parent | io-util: document EINTR situation a bit (diff) | |
download | systemd-00a60eaf5fcb3a0e415349aa649f2699550d26b0.tar.xz systemd-00a60eaf5fcb3a0e415349aa649f2699550d26b0.zip |
Merge pull request #25483 from poettering/ppoll-usec-eintr
ppoll() + EINTR fixes
Diffstat (limited to 'src/shared/utmp-wtmp.c')
-rw-r--r-- | src/shared/utmp-wtmp.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/shared/utmp-wtmp.c b/src/shared/utmp-wtmp.c index d2c8473c60..37a5bf7990 100644 --- a/src/shared/utmp-wtmp.c +++ b/src/shared/utmp-wtmp.c @@ -12,6 +12,7 @@ #include <utmpx.h> #include "alloc-util.h" +#include "errno-util.h" #include "fd-util.h" #include "hostname-util.h" #include "io-util.h" @@ -292,13 +293,15 @@ static int write_to_terminal(const char *tty, const char *message) { assert(message); fd = open(tty, O_WRONLY|O_NONBLOCK|O_NOCTTY|O_CLOEXEC); - if (fd < 0 || !isatty(fd)) + if (fd < 0) return -errno; + if (!isatty(fd)) + return -ENOTTY; p = message; left = strlen(message); - end = now(CLOCK_MONOTONIC) + TIMEOUT_USEC; + end = usec_add(now(CLOCK_MONOTONIC), TIMEOUT_USEC); while (left > 0) { ssize_t n; @@ -306,19 +309,21 @@ static int write_to_terminal(const char *tty, const char *message) { int k; t = now(CLOCK_MONOTONIC); - if (t >= end) return -ETIME; k = fd_wait_for_event(fd, POLLOUT, end - t); - if (k < 0) + if (k < 0) { + if (ERRNO_IS_TRANSIENT(k)) + continue; return k; + } if (k == 0) return -ETIME; n = write(fd, p, left); if (n < 0) { - if (errno == EAGAIN) + if (ERRNO_IS_TRANSIENT(errno)) continue; return -errno; |