diff options
author | brunsch <brunsch@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2001-03-01 21:39:06 +0000 |
---|---|---|
committer | brunsch <brunsch@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2001-03-01 21:39:06 +0000 |
commit | bd6501089e85b5d158aa709d633a7debe10e65c3 (patch) | |
tree | 9ac47e4d457c2ce1cdc8758500166666e9386524 /bin/PerlACE/Process_Unix.pm | |
parent | c8b45000a50cb51b5c3060f06e5c71c2492f8ebe (diff) | |
download | ATCD-bd6501089e85b5d158aa709d633a7debe10e65c3.tar.gz |
ChangeLogTag:Thu Mar 1 13:18:07 2001 Darrell Brunsch <brunsch@uci.edu>
Diffstat (limited to 'bin/PerlACE/Process_Unix.pm')
-rw-r--r-- | bin/PerlACE/Process_Unix.pm | 45 |
1 files changed, 37 insertions, 8 deletions
diff --git a/bin/PerlACE/Process_Unix.pm b/bin/PerlACE/Process_Unix.pm index 7cb18ca5034..b1c2a76e505 100644 --- a/bin/PerlACE/Process_Unix.pm +++ b/bin/PerlACE/Process_Unix.pm @@ -45,6 +45,7 @@ sub new my $self = {}; $self->{RUNNING} = 0; + $self->{IGNOREEXESUBDIR} = 0; $self->{PROCESS} = undef; $self->{EXECUTABLE} = shift; $self->{ARGUMENTS} = shift; @@ -66,6 +67,10 @@ sub Executable } my $executable = $self->{EXECUTABLE}; + + if ($self->{IGNOREEXESUBDIR}) { + return $executable; + } my $basename = basename ($executable); my $dirname = dirname ($executable). '/'; @@ -108,6 +113,17 @@ sub CommandLine () return $commandline; } +sub IgnoreExeSubDir +{ + my $self = shift; + + if (@_ != 0) { + $self->{IGNOREEXESUBDIR} = shift; + } + + return $self->{IGNOREEXESUBDIR}; +} + ############################################################################### # Spawn the process and continue; @@ -127,6 +143,16 @@ sub Spawn () return -1; } + if (!-f $self->{EXECUTABLE}) { + print STDERR "ERROR: Cannot Spawn: $self->{EXECUTABLE} not found\n"; + return -1; + } + + if (!-x $self->{EXECUTABLE}) { + print STDERR "ERROR: Cannot Spawn: $self->{EXECUTABLE} not executable\n"; + return -1; + } + FORK: { if ($self->{PROCESS} = fork) { @@ -154,9 +180,9 @@ sub Spawn () sub WaitKill ($) { my $self = shift; - my $maxtime = shift; + my $timeout = shift; - my $status = $self->TimedWait ($maxtime); + my $status = $self->TimedWait ($timeout); if ($status == -1) { print STDERR "ERROR: $self->{EXECUTABLE} timedout\n"; @@ -174,22 +200,25 @@ sub WaitKill ($) sub SpawnWaitKill ($) { my $self = shift; - my $maxtime = shift; + my $timeout = shift; if ($self->Spawn () == -1) { return -1; } - return $self->WaitKill ($maxtime); + return $self->WaitKill ($timeout); } -sub Terminate () +sub TerminateWaitKill ($) { my $self = shift; + my $timeout = shift; if ($self->{RUNNING}) { kill ('TERM', $self->{PROCESS}); } + + return $self->WaitKill ($timeout); } sub Kill () @@ -211,12 +240,12 @@ sub Wait () waitpid ($self->{PROCESS}, 0); } -sub TimedWait +sub TimedWait ($) { my $self = shift; - my $maxtime = shift; + my $timeout = shift; - while ($maxtime-- != 0) { + while ($timeout-- != 0) { my $pid = waitpid ($self->{PROCESS}, &WNOHANG); if ($pid != 0 && $? != -1) { return $?; |