in reply to Better way to search in the process table?

I would build a tree of parent ids:

use strict; use warnings; use Proc::ProcessTable; my $p = new Proc::ProcessTable; my $t = $p->table; my %tree; $tree{$_->pid} = $_->ppid for @$t; for my $process ( @$t ) { print $process->cmndline; my $pid = $process->pid; while( $pid > 1 ) { print "->$pid"; $pid = $tree{$pid} } print "->$pid\n"; }

Replies are listed 'Best First'.
Re^2: Better way to search in the process table?
by karlgoethebier (Abbot) on Mar 03, 2014 at 15:15 UTC