main ()
{
pid_t pid;
atexit( print_exit ); //注册该进程退出时的回调函数
pid=fork();
if (pid < 0)
printf("error in fork!");
else if (pid == 0)
printf("i am the child process, my process id is %d\n",getpid());
else
{
printf("i am the parent process, my process id is %d\n",getpid());
sleep(2);
wait();
}
}
i am the child process, my process id is 15806
the exit pid:15806
i am the parent process, my process id is 15805
the exit pid:15805