From e335e7d99c43a388842a63d24c356c401d19b2ae Mon Sep 17 00:00:00 2001 From: Matias Linares Date: Tue, 18 Aug 2020 11:10:01 -0300 Subject: Allow multiline strings on pstree --- lib/App/RunForPid.pm6 | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'lib') 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 { '(' ')' } - my regex pstree { * % '---' } + my regex pstree { + % ( '---' || '-+-' ) } - my $proc = run 'pstree', '-Tp', $pid.Str, :out; + my $proc = run 'pstree', '-TlAp', $pid.Str, :out; my $output = $proc.out.slurp: :close; - if $output ~~ // { - @process = gather for $ -> $proc { - take $proc.Str => $proc.Int - } + for $output.lines -> $line { + if $line ~~ // { + @process.append: gather for $ -> $proc { + take $proc.Str => $proc.Int + } + } } @process } -- cgit v1.2.3-70-g09d2