]> git.ozlabs.org Git - ppp.git/commitdiff
chat: Improve signal handling
authorPaul Mackerras <paulus@ozlabs.org>
Sat, 26 Nov 2022 07:18:03 +0000 (18:18 +1100)
committerPaul Mackerras <paulus@ozlabs.org>
Sat, 26 Nov 2022 07:18:03 +0000 (18:18 +1100)
This improves the way that signals are handled in chat.

First, signal handlers should not be calling functions which are not
async-signal-safe; doing so incurs the possibility of deadlock.  Thus
we can't call fatal() in signal handlers; instead we set 'fatalsig',
which functions both as a flag and as an indication of which signal
occurred, and check that at various points (basically after any
operation which might block) using the new function checksigs().

Secondly, using sigaction rather than signal() means that we can
control whether calls such as read() get restarted after a signal, and
whether the signal disposition gets reset when the signal is
delivered.  That simplifies sigalrm(); we no longer need to
re-register the handler, and we don't need the kludge of setting stdin
to non-blocking mode in order to get the read() in get_char() to
return.

This also removes a #ifdef ultrix since ultrix is no longer supported.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>

No differences found