/* Does this work? Beats me.. It's a good example of setting a signal * handler though! */ #include #include #include /* Warning: I do little error checking.. */ int pid; void handle_alarm() { kill(pid, SIGKILL); wait(); exit(); } int main(int argc, char **argv) { int timeout; char ip[256], buf[512]; signal(SIGALRM, handle_alarm); if (argc < 3) { printf("Usage: %s \n", argv[0]); exit(1); } pid = fork(); if (!pid) { /* Child here */ execl("/home/coder/test", "test", argv[2], NULL); } alarm(atoi(argv[1])); wait(); /* For the kid to finish */ }