aboutsummaryrefslogtreecommitdiff
path: root/tests/to.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2019-06-09 18:54:58 +0300
committerSergey Poznyakoff <gray@gnu.org>2019-06-09 18:54:58 +0300
commitc4dbd40477bb658cdc5c5e01b8f80057e587cd88 (patch)
tree73534b2cd2fff99e16c26ed4be8cf115cf4b3960 /tests/to.c
parentc33922f128403f5d05d24f19abeaad2368ce5467 (diff)
downloadpies-c4dbd40477bb658cdc5c5e01b8f80057e587cd88.tar.gz
pies-c4dbd40477bb658cdc5c5e01b8f80057e587cd88.tar.bz2
Test inetd components.
* lib/Makefile.am: Add urlconn.c * lib/libpies.h (url_connect): New proto. * lib/urlconn.c: New file. * src/piesctl.c (shttp_connect): Use url_connect. * tests/.gitignore: Update. * tests/Makefile.am: New auxtool: aux/in.test New test: inet.at * tests/aux/in.test: New file. * tests/inet.at: New file. * tests/iobuf.h: New file. * tests/nt.c: New file. * tests/testsuite.at: Add new test. * tests/to.c: explicitly terminate the child process on timeout.
Diffstat (limited to 'tests/to.c')
-rw-r--r--tests/to.c50
1 files changed, 41 insertions, 9 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;
+ }
+}
@@ -15,3 +34,3 @@ main (int argc, char **argv)
int status;
-
+
if (argc < 3)
@@ -32,2 +51,5 @@ main (int argc, char **argv)
+ signal (SIGALRM, sighan);
+ signal (SIGCHLD, sighan);
+
pid = fork ();
@@ -38,3 +60,3 @@ main (int argc, char **argv)
}
-
+
if (pid == 0)
@@ -47,4 +69,19 @@ main (int argc, char **argv)
alarm (n);
+ 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);
- alarm (0);
@@ -58,3 +95,3 @@ main (int argc, char **argv)
return WEXITSTATUS (status);
-
+
if (WIFSIGNALED (status))
@@ -69,6 +106 @@ main (int argc, char **argv)
}
-
-
-
-
-

Return to:

Send suggestions and report system problems to the System administrator.