On 05/24, David Laight wrote: > > From: Oleg Nesterov > > Sent: 24 May 2019 14:29 > > It seems that we all are just trying to confuse each other. I got lost. > > I'm always lost :-)
same here ;) > To my mind changing the signal mask should be enough to get a masked > signal handler called - even if the mask is reset before the syscall exits. well, the kernel doesn't do this, and on purpose. > There shouldn't be any need for an interruptible wait to be interrupted. can't parse ;) > I suspect that if you send a signal to a process that is looping > in userspace (on a different) the signal handler is called on the next > exit to userspace regardless as to whether the kernel blocks. > > epoll and pselect shouldn't be any different. They differ exactly because they manipulate the blocked mask, > Having the signal unmasked at any time should be enough to get it called. No. The sigmask passed to pselect() tells the kernel which signals should interrupt the syscall if it blocks. The fact that pselect() actually unblocks a signal is just the internal implementation detail. > > > I suspect you need to defer the re-instatement of the original mask > > > to the code that calls the signal handlers (which probably should > > > be called with the programs signal mask). > > > > This is what the kernel does when the signal is delivered, the original mask > > is restored after the signal handler runs. > > I'd have thought that the original signal mask (all blocked in the examples) > should be restored before the signal handler is called. No. And this means that if you have 2 pending signals, they both will be delivered. Unless of course sigaction->sa_mask includes the 2nd one. > After all the signal handler is allowed to modify the processes signal mask. only untill the handler returns. > I've had horrid thoughts about SIG_SUSPEND :-) google knows nothing about SIG_SUSPEND, neither me ;) Oleg.