-
Only if a signal was actually delivered to a thread that was blocked on sleep, [clock_]nanosleep or select, those calls should return -EINTR. Otherwise, they should resume with the timeout, accordingly adjusted in case of relative timeout. So far we returned -EINTR immediately which particularly disturbed the debugging of applications (SIGSTOP/CONT terminated those syscalls). This approach reuses the Linux restart mechanism to find out if those syscalls should be restarted or actually terminated after the signal was handled: Linux sets current->restart_block.fn in case a termination is required, unconditionally, thus also when the syscall did not return ERESTART_RESTARTBLOCK. We also use the restart_block.nanosleep.expires to transfer the remaining timeout to the restarted syscall. We can't use the original restart mechanism of Linux because it directs all ERESTART_RESTARTBLOCK through a special, Linux-only syscall. In our case, we would have to migrate the caller in that context to primary in order to resume the sleep, but this is not possible under Xenomai (we need to migration from within the syscall hooks). Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
36132cdb