[PATCH] Allow system call restarts upon signal interruption

Daniel Drake drake at endlessm.com
Wed May 13 07:15:43 PDT 2015


On Tue, May 12, 2015 at 8:18 PM, Michel Dänzer <michel at daenzer.net> wrote:
> On 13.05.2015 07:39, Daniel Drake wrote:
>> The X server frequently deals with SIGIO and SIGALRM interruptions.
>> If process execution is inside certain blocking system calls
>> when these signals arrive, e.g. with the kernel blocked on
>> a contended semaphore, the system calls will be interrupted.
>>
>> Some system calls are automatically restartable (the kernel re-executes
>> them with the same parameters once the signal handler returns) but
>> only if the signal handler allows it.
>>
>> Set SA_RESTART on the signal handlers to enable this convenient
>> behaviour.
>
> The discussion about this on IRC sounded to me like we don't want to do
> this for both signals, because at least one of them should interrupt
> select(). My guess would be that SIGIO should interrupt select() and
> thus shouldn't use SA_RESTART.

"man 7 signal" explains that select() is not affected by SA_RESTART behaviour.

Another thing to keep in mind is that this does not affect the
interruption aspect. With or without SA_RESTART, system calls will be
immediately interrupted by signals, at which point the relevant signal
handler will be executed.
SA_RESTART defines what happens *after* the signal handler returns:
for a certain set of system calls (and ioctls), if SA_RESTART is set,
the system call will be automatically executed again with the same
params as before. If SA_RESTART is not set, the system call will
return with error EINTR.

Daniel


More information about the xorg-devel mailing list