commit 7e7634ff619b02015b4f8b8f70f19b47dec0fdb2 Spenser Truex <spensertruexonline@gmail.com> 2019-04-27 21:53:06 -0700 Don't run the daemon if it is already running.
forking.pl | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-)
diff --git a/forking.pl b/forking.pl index 325d3c3..8d3ad1a 100755 --- a/forking.pl +++ b/forking.pl @@ -1,15 +1,18 @@ #!/usr/bin/perl use strict; use warnings; -my $pwd = $ARGV[0]; -open my $com, '<', "$pwd/commands.conf"; -for(<$com>) { - my $f = fork(); - if (defined $f) { - print; - chomp; - `$_`; +my $ps = `ps -e | grep monitor\\.pl`; +if(!($ps eq '')) { + my $pwd = $ARGV[0]; + open my $com, '<', "$pwd/commands.conf"; + for(<$com>) { + my $f = fork(); + if (defined $f) { + print; + chomp; + `$_`; + } } -} -while(1){;} + while(1){;} +}