aboutsummaryrefslogtreecommitdiff
path: root/lib/App
diff options
context:
space:
mode:
authorMatias Linares <matias.linares@comprandoengrupo.net>2020-08-18 11:10:01 -0300
committerMatias Linares <matias.linares@comprandoengrupo.net>2020-08-18 11:10:01 -0300
commite335e7d99c43a388842a63d24c356c401d19b2ae (patch)
tree786b6ad18f1787608c11039e9edcb12d9153aa7a /lib/App
parent00ddde1541d68bf1398f7e176082622ecfd27cda (diff)
downloadApp-RunForPid-e335e7d99c43a388842a63d24c356c401d19b2ae.tar.gz
Allow multiline strings on pstree
Diffstat (limited to 'lib/App')
-rw-r--r--lib/App/RunForPid.pm616
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
}