summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog-99b9
-rw-r--r--bin/ACEutils.pm15
-rw-r--r--bin/Process_Unix.pm28
-rw-r--r--bin/Process_Win32.pm18
4 files changed, 65 insertions, 5 deletions
diff --git a/ChangeLog-99b b/ChangeLog-99b
index 6ba4fe2c5f8..b519fd7e160 100644
--- a/ChangeLog-99b
+++ b/ChangeLog-99b
@@ -1,3 +1,12 @@
+Fri Jun 11 13:00:02 1999 Carlos O'Ryan <coryan@cs.wustl.edu>
+
+ * bin/ACEutils.pm:
+ * bin/Process_Unix.pm:
+ * bin/Process_Win32.pm:
+ Added new routines to wait for a process with a timeout, ditto
+ for the ACE::waitforfile() routine. They can be used to write
+ more reliable test drivers.
+
Fri Jun 11 12:10:00 1999 Chris Gill <cdgill@cs.wustl.edu>
* tests/RB_Tree_Test.{cpp, h (new)}: factored out class template
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;