printf("thread started...\n"); pthread_atfork(prepare,parent,child); sleep(2); printf("thread about to fork...\n"); if((pid=fork())<0) printf("fork error: %s\n",strerror(errno)); else if(pid==0) printf("child returned from fork\n"); else printf("parent returned from fork\n");