On Sat, Jul 15, 2017 at 10:23 AM, Gabor Szabo <szab...@gmail.com> wrote:

> If I understand correctly, then this means Ctrl-C sends a SIGINT to
> both the main process I ran and the child process I created using
> Proc::Async.  When I run kill -2 PID it only sends the SIGINT to the
> process I mentioned with PID.
> (Which in my case was the process I ran.)


> Then here is the problem which is closer to our original problem. I
> have another script that uses Proc::Async to launch the previous
> process. So now I have a main process, that has a child process which
> has a child process.
> use v6;
> my $proc = Proc::Async.new($*EXECUTABLE, "async.pl6");
> $proc.stdout.tap: -> $s { print $s };
> my $promise = $proc.start;
> sleep 10;
> $proc.kill;
> The "kill" there kill the immediate child but leaves the grandchild
> running.
> Is there a way to send a signal to all the processes created by that
> Proc::Async.new and to their children as well?

Not currently; Proc::Async would need to expose process group
functionality, so you could put the child in a new process group, let the
grandchild inherit that process group, and use a variant of the 'kill'
method to signal the whole process group instead of just the one child.

You *might* be able to simulate this by using NativeCall to invoke
setpgrp() in the child, and to invoke C's kill() in the parent with the
negated process ID of the child (thus indicating its associates process
group). You will also need to arrange to find out the child's pid, which
also doesn't appear to be available via Proc::Async (sigh) so you may well
need to have the child print that (again, if necessary, using NativeCall to
access C's getpid()).

This will all necessarily be POSIX specific; no chance of it working on

brandon s allbery kf8nh                               sine nomine associates
allber...@gmail.com                                  ballb...@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net

Reply via email to