diff options
author | coryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-06-11 18:01:25 +0000 |
---|---|---|
committer | coryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-06-11 18:01:25 +0000 |
commit | 8f76e90f54b742623b6b8f01d02390914967f3a8 (patch) | |
tree | 598aa33e79a12d2e141c3d7104cebf8523c6347b /bin | |
parent | 588c86183c45d669a6bc9b5e884689daf8d94327 (diff) | |
download | ATCD-8f76e90f54b742623b6b8f01d02390914967f3a8.tar.gz |
ChangeLogTag:Fri Jun 11 13:00:02 1999 Carlos O'Ryan <coryan@cs.wustl.edu>
Diffstat (limited to 'bin')
-rw-r--r-- | bin/ACEutils.pm | 15 | ||||
-rw-r--r-- | bin/Process_Unix.pm | 28 | ||||
-rw-r--r-- | bin/Process_Win32.pm | 18 |
3 files changed, 56 insertions, 5 deletions
diff --git a/bin/ACEutils.pm b/bin/ACEutils.pm index 2f7347c73b6..50bb743f15f 100644 --- a/bin/ACEutils.pm +++ b/bin/ACEutils.pm @@ -39,6 +39,19 @@ sub waitforfile sleep 1 while (!(-e $file)); } +sub waitforfile_timed +{ + my $file = shift; + my $maxtime = shift; + while ($maxtime-- != 0) { + if (-e $file) { + return 0; + } + sleep 1; + } + return -1; +} + $sleeptime = 5; -1;
\ No newline at end of file +1; diff --git a/bin/Process_Unix.pm b/bin/Process_Unix.pm index a4ad894f470..e4d983a80a7 100644 --- a/bin/Process_Unix.pm +++ b/bin/Process_Unix.pm @@ -3,6 +3,8 @@ package Process; $EXE_EXT = ""; +use POSIX ":sys_wait_h"; + sub Create { my $name = shift; @@ -20,7 +22,7 @@ sub Create { #child here exec $name." ".$args; - die "exec failed for <$name> <$args>"; + die "ERROR: exec failed for <$name> <$args>"; } elsif ($! =~ /No more process/) { @@ -31,23 +33,43 @@ sub Create else { # weird fork error - die "Can't fork: $!\n"; + print STDERR "ERROR: Can't fork: $!\n"; } } } -sub Kill +sub Terminate { my $self = shift; kill ('TERM', $self->[0]); # print STDERR "Process_Unix::Kill 'TERM' $self->[0]\n"; } +sub Kill +{ + my $self = shift; + kill ('KILL', $self->[0]); + # print STDERR "Process_Unix::Kill 'TERM' $self->[0]\n"; +} + sub Wait { my $self = shift; waitpid ($self->[0], 0); } +sub TimedWait +{ + my $self = shift; + my $maxtime = shift; + while ($maxtime-- != 0) { + waitpid ($self->[0], WNOHANG); + if ($? != -1) { + return $?; + } + sleep 1; + } + return -1; +} 1; diff --git a/bin/Process_Win32.pm b/bin/Process_Win32.pm index 400d778c6e4..ad1197329d4 100644 --- a/bin/Process_Win32.pm +++ b/bin/Process_Win32.pm @@ -35,10 +35,26 @@ sub Kill Win32::Process::Kill ($self->[0], -1); } +sub Terminate +{ + my $self = shift; + Win32::Process::Kill ($self->[0], -1); +} + sub Wait { my $self = shift; Win32::Process::Wait ($self->[0], INFINITE); } -1;
\ No newline at end of file +sub TimedWait +{ + my $self = shift; + my $maxtime = shift; + Win32::Process::Wait ($self->[0], $maxtime); + # @@ TODO figure out if we exit because of a timeout and return -1 + # in that case. + return 0; +} + +1; |