My point, this looks like a workaround for case when main program has SIG CHLD HANDLER like this:
$SIG{CHLD} = sub { die; } # intendent behaviour - die when any of child process terminate
such program will break after open("|$ftp -n") finished (because SIG CHILD will arrive).
correct main program handler should look like this:
my %children;
... # collect pids into %children
$SIG{CHLD} = sub { die if $children{$$}; } # only terminate if registered child die
Problem, that this workaround ( local $SIG{CHLD} = 'IGNORE') (for above problem in main program) actually
will break the main program if it is correct.
$SIG{CHLD} = sub { die if $children{$$}; } won't work during scope of local $SIG{CHLD} = 'IGNORE';
i.e. there is race condition - main program logic to terminate if child dies, is not executed if child die during ftp transfer.
On Fri Aug 09 00:19:07 2013, BINGOS wrote:
Show quoted text> On Sun Jul 28 07:17:03 2013, vsespb wrote:
> > I wonder why File::Fetch uses
> >
> > local $SIG{CHLD} = 'IGNORE';
> >
> > and does not even advertise that.
> >
> > 1. default signal action is IGNORE
> > 2. If main program has own SIG CHLD handler, this breaking it.
> > 3. If main program has own SIG CHLD handler and fails because
> > open("|$ftp -n")
> > delivers SIGCHLD, main program is broken, not this module. (some
> > other
> > modules like Cwd execute external command and main program should
> > handle it right)
>
> The local will localise the scope of this to the enclosing block.
>
> Presumably it is this way to counter the type of behaviour where
> people do not localise their SIG handlers.
>
> Cheers.