in reply to How to obtain current child process name?
.... but if you are on linux, and know the pid, then just read the file "/proc/$pid/cmdline"#!/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"; } }
... 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
|
|---|