Messages in this thread | | | Date | Tue, 21 Mar 2000 21:30:45 +0000 (/etc/localtime) | From | Diogo Zulli <> | Subject | execs and alarms - bug or feature ? |
| |
When a processes execs the child inherits a pending alarm...
(tty1:test)# gcc -o child child.c ; gcc -o exec exec.c (tty1:test)# ./exec Father Waiting.....timeout Child Waiting.....Alarm clock
----[ exec.c: ]------------------------------------------- #include <unistd.h> #include <stdio.h> #include <signal.h>
int stop = 0;
void timeout(int ignored) { printf("timeout\n"); stop = 1; } int main(void) { signal(SIGALRM, timeout); alarm(0); alarm(5);
for (printf("Father Waiting"); !stop;) { printf("."); fflush(stdout); sleep(1); } alarm(0); alarm(5);
execlp("./child", "./child", NULL); }
---[ child.c ]---------------------------------------- #include <unistd.h> #include <stdio.h>
int main(void) { for (printf("Child Waiting");;) { printf("."); fflush(stdout); sleep(1); } }
--------------
Linux 2.2.14 GNU C Library stable release version 2.1.2, by Roland McGrath et al. Slack7 K6II-450, 128MB egcs-2.91.66
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |