On 11 November 2013 16:56, Anthony Liguori <[email protected]> wrote:
> On Mon, Nov 11, 2013 at 8:50 AM, Eric Blake <[email protected]> wrote:
>> Here's a hint: ioctl() can clobber errno. But if a signal handler is
>> called in the middle of other code that is using errno, then the handler
>> MUST restore the value of errno before returning, if it is to guarantee
>> that the interrupted context won't be corrupted.
>
> Isn't this precisely why EINTR exists?
EINTR won't help you in the case like:
ret = some_syscall();
[execution returns from syscall, with errno set to X]
[signal happens here; handler trashes errno]
if (ret < 0) {
use errno;
}
EINTR exists mostly because properly resuming syscalls
was too hard for Bell Labs :-)
-- PMM