Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env perl
- use strict;
- use warnings;
- use Data::Dumper;
- use Proc::ProcessTable;
- print Dumper [children(shift)];
- sub children {
- _children(Proc::ProcessTable->new->table, shift);
- }
- sub _children {
- my ($pt, $pid) = @_;
- my @pids;
- for my $ps (@$pt) {
- if ($ps->ppid == $pid) {
- push @pids, $ps->pid, _children($pt, $ps->pid);
- }
- }
- @pids;
- }
- 1;
Add Comment
Please, Sign In to add comment