Re: [PATCH] drbd: do not ignore signals in threads

Philipp Reisner
2019-08-12T13:28:46Z

Hi David,

[...]
> While our code is 'out of tree' (you really don't want it - and since
> it still uses force_sig() is fine) I suspect that the 'drdb' code
> (with Christoph's allow_signal() patch) now loops in kernel if a user
> sends it a signal.

I am not asking for that out of tree code. But you are welcome to learn
from the drbd code that is in the upstream kernel.
It does not loop if a root sends a signal, it receives it and ignores it.

> If the driver (eg drdb) is using (say) SIGINT to break a thread out of
> (say) a blocking kernel_accept() call then it can detect the unexpected
> signal (maybe double-checking with signal_pending()) but I don't think
> it can clear down the pending signal so that kernel_accept() blocks
> again.

You do that with flush_signals(current)

What we have do is, somewhere in the main loop:

if (signal_pending(current)) {
flush_signals(current);
if (!terminate_condition()) {
warn(connection, "Ignoring an unexpected signal\n");
continue;
}
break;
}
}

--
LINBIT | Keeping The Digital World Running

DRBD® and LINBIT® are registered trademarks of LINBIT, Austria.