lkml.org 
[lkml]   [2000]   [Mar]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
Subjectexecs 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/

\
 
 \ /
  Last update: 2005-03-22 13:57    [W:0.276 / U:0.924 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site