Hi All, Fedora 33 I know I can get this information from a system call to "ps", but is there a way to tell if a program in running from Raku? Many thanks, -T
![]() |
1 |
![]() |
Running ps is probably as good as anything, but in linux you could always just poke around under /proc, e.g. Loop over /proc/*/cmdline and look for it.
![]() |
1 |
![]() |
Follow up: $PsStr = qqx ( ps ax ); if $PsStr.contains( "gnucash" ) { PrintGreen( "GnuCash is running\n\n" ); } else { # qqx ( gnucash ); my $pA = Proc::Async.new( "/usr/bin/gnucash" ); $pA.start; PrintGreen( "GnuCash started\n\n" ); }
![]() |
0 |
![]() |
If the reason you want to run ps is to check whether a specific program is running, I would very strongly suggest using the pgrep utility and checking its exit code. There are many advantages to using pgrep over trying to parse the output of ps, except for the case when you invoke ps with a very, very specific set of options and columns, but... that's pretty much equivalent to running pgrep anyway ;) G'luck, Peter
![]() |
0 |
![]() |
pgrep is sweet!
![]() |
0 |
![]() |