#include
#include
#include
#include
#include
#include
#include
#include
#include
void pr()
{
printf("just test this is exit\n");
}
int main(int argc, char **argv[])
{
int pid;
int count=0;
pid = fork();
if(pid < 0) printf("error fork\n");
else if(pid == 0){
while(1)
{
printf("now count = %d\n", count++);
sleep(1);
}
}
else {
time_t now_t;
time_t now_s;
struct tm now_tm;
now_s = now_t = time(NULL);
printf("now parent is waiting\n");
while ((now_t - now_s)< 10)
{
now_t = time(NULL);
}
kill(pid, SIGKILL);
atexit(pr);
printf("now end\n");
exit(0);
}
}
阅读(576) | 评论(0) | 转发(0) |