aboutsummaryrefslogtreecommitdiff
path: root/tests/to.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/to.c')
-rw-r--r--tests/to.c44
1 files changed, 38 insertions, 6 deletions
diff --git a/tests/to.c b/tests/to.c
index 6511a54..6874bfd 100644
--- a/tests/to.c
+++ b/tests/to.c
@@ -1 +1,2 @@
+#include <config.h>
#include <stdlib.h>
@@ -6,2 +7,20 @@
#include <sys/wait.h>
+#include <signal.h>
+
+int volatile got_sigchld, got_sigalrm;
+
+void
+sighan (int sig)
+{
+ switch (sig)
+ {
+ case SIGCHLD:
+ got_sigchld = 1;
+ break;
+
+ case SIGALRM:
+ got_sigalrm = 1;
+ break;
+ }
+}
@@ -32,2 +51,5 @@ main (int argc, char **argv)
+ signal (SIGALRM, sighan);
+ signal (SIGCHLD, sighan);
+
pid = fork ();
@@ -47,4 +69,19 @@ main (int argc, char **argv)
alarm (n);
- ret = wait (&status);
+ while (1)
+ {
+ pause ();
+ if (got_sigchld)
+ {
alarm (0);
+ break;
+ }
+ if (got_sigalrm)
+ {
+ fprintf (stderr, "%s: timed out\n", progname);
+ kill (pid, SIGKILL);
+ exit (127);
+ }
+ }
+
+ ret = wait (&status);
@@ -69,6 +106 @@ main (int argc, char **argv)
}
-
-
-
-
-

Return to:

Send suggestions and report system problems to the System administrator.