in reply to open3() problem

OK, I can make the question less vague now.

By chance, another recent question set me thinking about my use of open3().

So I toyed with the code a bit, and found something that makes a difference.

The original code is

... setpgrp(0,0); sub killgroup { # Make sure all child processes are killed too. my $sig = shift; local $SIG{$sig} = 'IGNORE'; # don't kill ourselves again $Interrupted = 1; kill($sig, -$$); }; local $SIG{INT} = \&killgroup; local $SIG{QUIT} = \&killgroup; local $SIG{ABRT} = \&killgroup; local $SIG{TERM} = \&killgroup; local *CATCHERR = IO::File->new_tmpfile; my $pid = open3(gensym, \*CATCHOUT, ">&CATCHERR", "$cmd $args"); ...

If I comment out the four lines beginning local $SIG, then it works just like it used to.

Has something changed in Perl since 5.10.1 that would affect this?

Replies are listed 'Best First'.
Re^2: Vague segfault question
by ikegami (Patriarch) on Feb 03, 2012 at 19:47 UTC
    kill($sig, -$$);? Don't you mean kill(-$sig, $$);? kill

      Thanks for your reply.

      I'm confused now about the use of kill.

      Kill says

      Unlike in the shell, if SIGNAL is negative, it kills process groups instead of processes.

      But perlipc says

      Sending a signal to a negative process ID means that you send the signal to the entire Unix process group.
      Which of those is true?

        Which of those is true?

        Both, they're not mutually exclusive :) if you keep reading it also says

        The behavior of kill when a *PROCESS* number is zero or negative depends on the operating system. For example, on POSIX-conforming systems, zero will signal the current process group and -1 will signal all processes.

        See also what perlport#kill says