in reply to How to obtain current child process name?

... you may be looking for something like
#!/usr/bin/perl -w use strict; use Proc::ProcessTable; my $t1 = new Proc::ProcessTable; my $pid; my $commandline = shift || $0; foreach my $p (@{$t1->table}){ # reverse this logic if($p->cmndline =~ /\Q$commandline\E/){ $pid = $p->pid; print "$pid\n"; } }
.... but if you are on linux, and know the pid, then just read the file "/proc/$pid/cmdline"

... the problem becomes this.... the $pid you have in hand may not be the actual child, but instead the shell running the child..... look up killfam and see Killing children's of children for examples of the problem


I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku