Fix signal handling.
authorAndre Noll <maan@systemlinux.org>
Thu, 2 Feb 2012 16:07:35 +0000 (17:07 +0100)
committerAndre Noll <maan@systemlinux.org>
Thu, 23 Feb 2012 21:31:30 +0000 (22:31 +0100)
commit2d7a4d61bfa10e3f462053936dcf7fd416b629d0
treeba4a5157aa967d8735a4cf93968c4b94794ea426
parenta159b67466fcb6cc38b9daf855051ce807669bc5
Fix signal handling.

Using signal() to set the disposition of a signal is always a bad idea
as POSIX does not specify whether a system call which was interrupted
should be restarted or not.

For interactive sessions, the Linux behaviour is to automatically
restart slow system calls, specifically read(2) in case nothing had
been read before the interrupt arrived. This is rather unfortunate
as adu calls fgets(3) (hence read(2)) in an endless loop to read the
user input. Therefore automatically restarted read() calls result
in interactive sessions that can not be terminated easily, as was
noticed by Sebastian Stark.

This patch makes the signal initialization code call sigaction()
instead of signal() to set up the handlers. This buys us well-defined
semantics across all operating systems, namely to *not* restart slow
system calls. As a side effect of this change, interactive sessions
can now be terminated by sending SIGINT (e.g., by pressing CTRL+C).
adu.c
error.h