tty-askpw-agent: react to SIGTERM while waiting for console
I noticed that systemd-tty-password-agent would time out when asked to stop via SIGTERM, and eventually be killed, under some circumstances. It took me a while but i figured out what was going on: systemd-ask-pw-agent blocks SIGTERM because it wants async notifications on SIGTERM via signalfd() to listen on. That mostly works great: except for one case: if we actually get a pw query request, and hence need to acquire the terminal: we issue open_terminal() in that case, but if the terminal is used otherwsie we'll hang, and because SIGTERM is blocked we'll hang and cannot exit cleanly. Address that: optionally, in acquire_terminal() look for SIGTERM by unblcking the signal mask via ppoll() while we wait.
This commit is contained in:
+2
-2
@@ -188,7 +188,7 @@ int pipe_eof(int fd) {
|
||||
return !!(r & POLLHUP);
|
||||
}
|
||||
|
||||
int ppoll_usec(struct pollfd *fds, size_t nfds, usec_t timeout) {
|
||||
int ppoll_usec_full(struct pollfd *fds, size_t nfds, usec_t timeout, const sigset_t *ss) {
|
||||
int r;
|
||||
|
||||
assert(fds || nfds == 0);
|
||||
@@ -211,7 +211,7 @@ int ppoll_usec(struct pollfd *fds, size_t nfds, usec_t timeout) {
|
||||
if (nfds == 0)
|
||||
return 0;
|
||||
|
||||
r = ppoll(fds, nfds, timeout == USEC_INFINITY ? NULL : TIMESPEC_STORE(timeout), NULL);
|
||||
r = ppoll(fds, nfds, timeout == USEC_INFINITY ? NULL : TIMESPEC_STORE(timeout), ss);
|
||||
if (r < 0)
|
||||
return -errno;
|
||||
if (r == 0)
|
||||
|
||||
Reference in New Issue
Block a user