Re: [Nbd] [PATCH] nbd-client: do not leave child processes in the zombie state
- To: "Dmitry V. Levin" <ldv@...1147...>
- Cc: nbd-general@lists.sourceforge.net
- Subject: Re: [Nbd] [PATCH] nbd-client: do not leave child processes in the zombie state
- From: Wouter Verhelst <w@...112...>
- Date: Thu, 21 Jun 2012 21:51:55 +0200
- Message-id: <20120621195155.GA25502@...3...>
- In-reply-to: <20120615234323.GB9699@...1147...>
- References: <20120615234323.GB9699@...1147...>
On Sat, Jun 16, 2012 at 03:43:23AM +0400, Dmitry V. Levin wrote:
> Change SIGCHLD handler to SIG_DFL with SA_NOCLDWAIT flag set, to avoid
> transforming child processes into zombies when they terminate. Since
> the main process is inevitably blocked in NBD_DO_IT ioctl at the time
> when child processes terminate, this is the simplest way to get rid of
> zombie processes.
Thanks, applied.
> Signed-off-by: Dmitry V. Levin <ldv@...1147...>
> ---
> nbd-client.c | 11 +++++++++++
> 1 files changed, 11 insertions(+), 0 deletions(-)
>
> diff --git a/nbd-client.c b/nbd-client.c
> index 7a526b9..2321e7b 100644
> --- a/nbd-client.c
> +++ b/nbd-client.c
> @@ -35,6 +35,7 @@
> #include <stdlib.h>
> #include <sys/mount.h>
> #include <sys/mman.h>
> +#include <signal.h>
> #include <errno.h>
> #include <getopt.h>
> #include <stdarg.h>
> @@ -571,6 +572,16 @@ int main(int argc, char *argv[]) {
> #endif
> do {
> #ifndef NOFORK
> +#ifdef SA_NOCLDWAIT
> + struct sigaction sa;
> +
> + sa.sa_handler = SIG_DFL;
> + sigemptyset(&sa.sa_mask);
> + sa.sa_flags = SA_NOCLDWAIT;
> + if (sigaction(SIGCHLD, &sa, NULL) < 0)
> + err("sigaction: %m");
> +#endif
> +
> if (!fork()) {
> /* Due to a race, the kernel NBD driver cannot
> * call for a reread of the partition table
> --
> ldv
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Nbd-general mailing list
> Nbd-general@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/nbd-general
>
--
The volume of a pizza of thickness a and radius z can be described by
the following formula:
pi zz a
Reply to: