allow size set
[tridge/junkcode.git] / timed_command.c
1 /* run a command with a limited timeout
2    tridge@samba.org, January 2002
3 */
4 #include <stdio.h>
5 #include <string.h>
6 #include <stdlib.h>
7 #include <unistd.h>
8
9 static void usage(void)
10 {
11         printf("
12 timed_command <time> <command>
13 ");
14 }
15
16 int main(int argc, char *argv[])
17 {
18         int maxtime;
19
20         if (argc < 3) {
21                 usage();
22                 exit(1);
23         }
24
25         maxtime = strtol(argv[1], NULL, 0);
26         alarm(maxtime);
27         return execvp(argv[2], argv+2);
28 }