bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-gnulib] addition: wait-process.h, wait-process.c


From: Bruno Haible
Subject: Re: [Bug-gnulib] addition: wait-process.h, wait-process.c
Date: Wed, 1 Oct 2003 12:15:36 +0200
User-agent: KMail/1.5

Paul Eggert wrote:
> > So this was mainly needed because the 'diff' subprocess ignores
> > SIGINT, but you want it nevertheless to exit as soon as the 'sdiff'
> > process exits?
>
> No, diff doesn't ignore SIGINT, but someone might kill sdiff (e.g.,
> using 'kill') without killing its subprocesses.  In that case sdiff
> should clean up nicely.  Similarly for other programs that have
> subprocesses.

I think the responsibility for cleaning up the children processes at all
is in the OS, not in the program itself, because:
  1) When using 'kill -9' or abort() or some such, the program has no chance
     to clean up anything,
  2) Unix already cleans up the children processes, in two steps:
     - The child process writes to a pipe with no listeners and thus gets a
       SIGPIPE signal,
     - The init(1) process does a waitpid() to remove the zombie child.

The code in sdiff is therefore only an optimization to avoid burning some
CPU cycles in the child process (until the child process writes something),
and it doesn't work in all cases (namely with 'kill -9').

Therefore I don't want to copy this functionality into wait-process.c:
Too much complexity for little gain.

Bruno





reply via email to

[Prev in Thread] Current Thread [Next in Thread]