diff tests/test-ptsname.c @ 15652:66bab2a591f5

ptsname tests: Let the test fail rather than hang (e.g. on AIX 5.1). * tests/test-ptsname.c (main): Terminate the test if it takes longer than 5 seconds. * modules/ptsname-tests (configure.ac): Test for alarm.
author Bruno Haible <bruno@clisp.org>
date Mon, 19 Sep 2011 01:02:09 +0200
parents 97fc9a21a8fb
children 8250f2777afc
line wrap: on
line diff
--- a/tests/test-ptsname.c
+++ b/tests/test-ptsname.c
@@ -22,6 +22,7 @@
 SIGNATURE_CHECK (ptsname, char *, (int));
 
 #include <fcntl.h>
+#include <signal.h>
 #include <stdio.h>
 #include <string.h>
 #include <unistd.h>
@@ -54,6 +55,13 @@
 int
 main (void)
 {
+#if HAVE_DECL_ALARM
+  /* Declare failure if test takes too long, by using default abort
+     caused by SIGALRM.  */
+  signal (SIGALRM, SIG_DFL);
+  alarm (5);
+#endif
+
   {
     int fd;
     char *result;