diff options
Diffstat (limited to 'lib/App')
-rw-r--r-- | lib/App/RunForPid.pm6 | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/App/RunForPid.pm6 b/lib/App/RunForPid.pm6 index dbaa5a8..a82e530 100644 --- a/lib/App/RunForPid.pm6 +++ b/lib/App/RunForPid.pm6 @@ -17,18 +17,20 @@ sub get-pid { sub parse-process-tree(Int $pid) { my @process; - my regex name { \w+ } + my regex name { \w <[\w -]> + } my regex pid { \d+ } my regex proc { <name=name> '(' <pid=pid> ')' } - my regex pstree { <proc>* % '---' } + my regex pstree { <proc>+ % ( '---' || '-+-' ) } - my $proc = run 'pstree', '-Tp', $pid.Str, :out; + my $proc = run 'pstree', '-TlAp', $pid.Str, :out; my $output = $proc.out.slurp: :close; - if $output ~~ /<pstree>/ { - @process = gather for $<pstree><proc> -> $proc { - take $proc<name>.Str => $proc<pid>.Int - } + for $output.lines -> $line { + if $line ~~ /<pstree>/ { + @process.append: gather for $<pstree><proc> -> $proc { + take $proc<name>.Str => $proc<pid>.Int + } + } } @process } |