Subject: bug#227: nbd-client: At shutdown nbd-client disabled before file-systems could be cleanly unmounted

From: Mark Hindley <[email-masked]>
Date: Thu, 16 Feb 2023 15:22:44 +0000

Control: tags -1 upstream

David,

I know it has been a long time, but thanks for this.

On Mon, Jul 16, 2018 at 01:52:51AM +0200, David Kuehling wrote:
> Short summary of the problem: during shutdown /etc/init.d/sendsigs calls
> killall5 binary from sysvinit-utils, killing almost all running
> processes.
> 
> Of course it never should kill nbd-client, so the /etc/init.d/nbd-client
> script is smart enough to register its PID to be exempt from sendsig's
> action: by recording it in the /run/sendsigs.omit.d/nbd-cient file.
> 
> These PIDs are then collected by /etc/init.d/sendsig and passed as "-o
> NNN" options to killall5 which spares those processes from premature
> termination.
> 
> However, before killall5 goes on to kill all the other processes, it
> does a:
> 
> 	/* Now stop all processes. */
> 	kill(-1, SIGSTOP);
> 
> And when it's done, it does:
> 
> 	/* And let them continue. */
> 	kill(-1, SIGCONT);
> 
> These SIGSTOP, SIGCONT signals are passed to all processes, including
> nbd-client.  Unfortunately nbd-client is written in a way that makes it
> unable to handle any signals delivered while it is inside an ioctl call,
> and it looses its server connection on SIGSTOP, totally breaking the
> block devices it provides.
> 
> What would be the right way to prevent this problem?  Fix sysvinit?

My inclination here is that killall5 shouldn't send any signals (including a
STOP CONT pair) to processes that have registered to be omitted.

Copying Jesse Smith the sysvinit maintainer.

Jesse what do you think? Is it possible to avoid that?

Thanks

Mark