Re: Lack of Documentation about SA_RESTART...

Linus Torvalds
2005-07-24T00:30:58Z

On Mon, 11 Jul 2005, Theodore Ts'o wrote:
>
> According to the Single Unix Specification V3, all functions that
> return EINTR are supposed to restart if a process receives a signal
> where signal handler has been installed with the SA_RESTART flag.

That can't be right.

Some operations, like "select()" and "pause()" always return EINTR, and
indeed, real applications will break if you always restart. Restarting a
pause() would be nonsensical.

This is why the kernel has ERESTARTSYS (restart always) and ERESTARTNOHAND
(restart if the signal had no handler) which will be turned into EINTR if
SA_RESTART isn't set. And even then, there are some ops that just always
use EINTR and don't even try to restart.

> There may be a few places in the kernel where this isn't happenning,
> that's what the specification states.

The specs are broken, and apparently don't take real life (or sanity -
pause() in particular just doesn't make sense if restarted) into account.

Afaik, the historical BSD behaviour (which is what SA_RESTART is all
about) always was to just restart some system calls, not all of them.

Linus