Victor86B digital multimeter app
[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("timed_command <time> <command>\n");
12 }
13
14 int main(int argc, char *argv[])
15 {
16         int maxtime;
17
18         if (argc < 3) {
19                 usage();
20                 exit(1);
21         }
22
23         maxtime = strtol(argv[1], NULL, 0);
24         alarm(maxtime);
25         return execvp(argv[2], argv+2);
26 }