Guest User

Untitled

a guest
Jul 18th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. #!/usr/bin/env perl
  2. use strict;
  3. use warnings;
  4. use Data::Dumper;
  5. use Proc::ProcessTable;
  6.  
  7. print Dumper [children(shift)];
  8.  
  9. sub children {
  10. _children(Proc::ProcessTable->new->table, shift);
  11. }
  12. sub _children {
  13. my ($pt, $pid) = @_;
  14. my @pids;
  15. for my $ps (@$pt) {
  16. if ($ps->ppid == $pid) {
  17. push @pids, $ps->pid, _children($pt, $ps->pid);
  18. }
  19. }
  20. @pids;
  21. }
  22.  
  23. 1;
Add Comment
Please, Sign In to add comment