correct response to -ERESTARTSYS from wait_event_interruptible_timeout()

Jeff Haran Jeff.Haran at citrix.com
Wed Mar 19 20:33:36 EDT 2014


Hi,

I am struggling a bit to understand how a driver ioctl() handler should respond when its call to wait_event_interruptible_timeout() returns -ERESTARTSYS.

My understanding is that -ERESTARTSYS means the process caught a signal during the wait. Comments in include/linux/errno.h indicate that -ERESTARTSYS should never be returned to user space. Seems that when this happens, -EINTR should be returned instead. However, man 7 signal indicates that if a signal handler is registered using SA_RESTART, the system call should be restarted.

I've tried to follow the ioctl() system call logic from SYSCALL_DEFINE3(ioctl, ...) in fs/ioctl.c down to the driver ioctl() functions and I haven't seen any code that appears to implement this restarting behavior. I suppose this could be something that glibc implements.

So my question is "Restarted by whom?"

To be more specific, is it up to the device driver ioctl handler to implement this restarting behavior by somehow inspecting the flags of the signal handlers registered with the process and call into wait_event_interrupible_timeout() again when SA_RESTART is set?

Or is the restarting behavior implemented farther up the call tree from the driver ioctl handler and if so, what should the ioctl handler return to ensure that the system call returns to user space with EINTR or gets restarted according to SA_RESTART?

Thanks,

Jeff Haran




More information about the Kernelnewbies mailing list