From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fa528,689ead9f7415a732,start X-Google-Attributes: gidfa528,public X-Google-ArrivalTime: 2002-08-28 16:13:17 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!newsfeed.gamma.ru!srcc!Gamma.RU!roma From: Roman Prokhorov Newsgroups: comp.unix.tru64 Subject: fork() problem Date: Thu, 29 Aug 2002 03:13:18 +0400 Organization: Gamma NNTP server Moscow Russia Message-ID: NNTP-Posting-Host: roma.ttk.ru X-Trace: news.gamma.ru 1030576396 36399 195.170.229.76 (28 Aug 2002 23:13:16 GMT) X-Complaints-To: abuse@gamma.ru NNTP-Posting-Date: Wed, 28 Aug 2002 23:13:16 +0000 (UTC) Keywords: 318629621 User-Agent: MT-NewsWatcher/3.1 (PPC) Xref: archiver1.google.com comp.unix.tru64:8510 Hi, I have a problem: Under Tru64 the fork() called from a thread freezes. This doesn't happen on the other Unixes I tried. See my code below, did I do anything wrong? I discovered that I can unfreeze the fork() when I call sleep() from the main thread. What sleep() realy does? #include #include #include #include #include void fork_handler1() { printf("prepare handler called\n"); } void fork_handler2() { printf("parent handler called\n"); } void fork_handler3() { printf("child handler called\n"); } void func(void *pData) { pthread_atfork(fork_handler1,fork_handler2,fork_handler3); printf("thread launched\n"); if(fork()==0) { printf("new fork started, pid=%d\n",getpid()); exit(0); } else { printf("old fork running, pid=%d\n",getpid()); } } main() { char buf[10]; pthread_t theThread; if(!pthread_create(&theThread,NULL,(void *(*)(void *))&func,NULL)) { pthread_detach(theThread); } else { printf("Unable to launch a thread\n"); } printf("hit Enter, please\n"); fgets(buf,sizeof(buf),stdin); //sleep(1); printf("hit Enter again, please\n"); fgets(buf,sizeof(buf),stdin); } -- Roman