[Top][All Lists]

[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: Thu, 2 Oct 2003 14:31:38 +0200
User-agent: KMail/1.5

Paul Eggert wrote:
> > 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').
> It also avoids leftover processes in some cases, e.g. if the child
> process is waiting on a device or a pipe or something.

And in function cleanup() it also removes some temp file. GNU gettext also
needs this (see gettext/gettext-tools/src/write-java.c). Basically every
program which uses mkstemp or mkdtemp needs this.

> Applications that
> are killed "nicely" by signals (common in daemons) will probably need
> it.

I see. Thanks for explaining.

The way I would implement this kind of cleanup in gnulib is in two steps:

1) A general at_fatal_signal facility, similar to atexit, which allows to
   register cleanup handlers for those fatal signals that can be caught.
   The known limitation is that it cannot work with 'kill -9', but it's still
   useful for SIGINT and similar.

2) Two boolean arguments kill_at_exit and kill_at_fatal_signal, that will
   be passed to create_pipe_{in,out,bidi}() and execute(), and which will
   have the effect to register a cleanup handler via atexit or at_fatal_signal
   if desired.

How does that sound?


reply via email to

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