add alarm handler
authortridge <>
Wed, 29 Sep 2004 18:00:24 +0000 (18:00 +0000)
committertridge <>
Wed, 29 Sep 2004 18:00:24 +0000 (18:00 +0000)
fnmatch/ms_fnmatch.c

index c605c64..3a5fc2a 100644 (file)
@@ -3,6 +3,7 @@
 #include <string.h>
 #include <unistd.h>
 #include <time.h>
+#include <signal.h>
 #include <ctype.h>
 
 /*
@@ -130,12 +131,19 @@ static void randstring(char *s, int len, const char *chars)
        *s = 0;
 }
 
+static void sig_alrm(int sig)
+{
+       printf("Too slow!!\n");
+       exit(0);
+}
 
 int main(void)
 {
        int i;
        srandom(time(NULL));
 
+       signal(SIGALRM, sig_alrm);
+
        alarm(2);
        fnmatch_test("********************************************.dat", "foobar.txt");
        fnmatch_test("*<*<*<*<*<*<*<*<*<*<*<*<*<*<*<*<*<*<*<*<*<*<.dat", "foobar.txt");