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/
This archive was generated by hypermail 2b29 : Thu Mar 23 2000 - 21:00:35 EST