From: Peter J. Holzer on
On 2010-07-25 04:00, PerlFAQ Server <brian(a)theperlreview.com> wrote:
> 8.35: How do I close a process's filehandle without waiting for it to complete?
>
> Assuming your system supports such things, just send an appropriate
> signal to the process (see "kill" in perlfunc). It's common to first
> send a TERM signal, wait a little bit, and then send a KILL signal to
> finish it off.

To me "closing a file handle" and "killing a process" are two completely
different concepts. If somebody asks this question and it turns out that
killing the process is what they need to do then I smell an XY problem.

hp

From: Ben Morrow on

Quoth "Peter J. Holzer" <hjp-usenet2(a)hjp.at>:
> On 2010-07-25 04:00, PerlFAQ Server <brian(a)theperlreview.com> wrote:
> > 8.35: How do I close a process's filehandle without waiting for it to
> complete?
> >
> > Assuming your system supports such things, just send an appropriate
> > signal to the process (see "kill" in perlfunc). It's common to first
> > send a TERM signal, wait a little bit, and then send a KILL signal to
> > finish it off.
>
> To me "closing a file handle" and "killing a process" are two completely
> different concepts. If somebody asks this question and it turns out that
> killing the process is what they need to do then I smell an XY problem.

The question would be better phrased as 'How do I close a piped-open
filehandle without waiting for the process on the other end to terminate
on its own?', or something like that. When you close a piped-open
filehandle, perl will wait(2) for the process it started, which may take
forever if the process has got stuck somehow.

I can easily see this being a FAQ by people who start with 'why is my
filehandle taking forever to close', not realising that their question
should be 'how do I kill this child process': that is, the FAQ is
attempting to *address* a (once?) common XY problem. It might be better
for the answer to explain the problem in more detail, making it clear
that the filehandle is not really part of the problem.

Ben