The trick is to keep track of the PID as you launch the process. On non-Windows systems, this is easiest done through the magic of exec, which replaces the current process by the other process, keeping the PID ($$) the same. So you can store $$ and then exec the "real" process:
sub launch { my ($pid_file,@process_and_args) = @_; open my $fh, '>', $pid_file # or print to STDOUT for easier handli +ng by ssh? or die "Couldn't create '$pid_file': $!"; print {$fh} $$; exec(@process_and_args) or die "Couldn't launch [@process_and_args]: $!"; };
You have to decide whether to output the PID to a file or to directly output it to STDOUT and read it from your ssh launcher and store it in the controlling master.
In reply to Re: how to kill deattached process
by Corion
in thread how to kill deattached process
by baxy77bax
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |