]> git.ozlabs.org Git - ppp.git/commit
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)
commit184aaa447eea970cc7cb680263b104636e6e7a31
treed005eea4e3b55d4a366eceb139f626738c072643
parentc42bade9f55544e30ec9d369c557742d36b7881e
chat: Improve signal handling

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>
chat/chat.c