Received: from SOUTH-STATION-ANNEX.MIT.EDU by po7.MIT.EDU (5.61/4.7) id AA28673; Thu, 22 Feb 96 07:38:07 EST
Received: from gw4.att.com by MIT.EDU with SMTP
	id AA25810; Thu, 22 Feb 96 07:37:48 EST
To: proven@MIT.EDU
Received: by ig4.att.att.com id AA06994; Thu, 22 Feb 96 07:30:46 EST
Date: Thu, 22 Feb 96 07:30:46 EST
From: uucp@ig4.att.att.com
Message-Id: <9602221230.AA06994@ig4.att.att.com>
Subject: mail warning
Apparently-To: MIT.EDU!proven@ig4.att.att.com

We have been unable to contact machine 'pearl' to deliver mail you sent.
Our attempts to deliver your mail will continue for 6 more day(s).
No further action is required by you.
The following mail has not been delivered:

	pearl!mail erk   (Date 02/20)

If you wish to kill the job, contact our administrator at
postmaster@att.com (att!postmaster) and ask to kill UUCP job pearlJ5d70.

Sincerely,
postmaster@att.com
#################### Data File: ####################
From ig4.att.att.com!MIT.EDU!proven Tue Feb 20 15:43:15 1996 remote from att
Received: from att!MIT.EDU by ig4.att.att.com id AA22653; Tue, 20 Feb 96 15:43:15 EST
Received: by gw4.att.com; Tue Feb 20 15:45:54 EST 1996
Received: from YAZ-PISTACHIO.MIT.EDU by MIT.EDU with SMTP
	id AA02381; Tue, 20 Feb 96 15:26:14 EST
Received: by yaz-pistachio.MIT.EDU (5.57/4.7) id AA11362; Tue, 20 Feb 96 15:26:41 -0500
Message-Id: <9602202026.AA11362@yaz-pistachio.MIT.EDU>
To: Samuel Tardieu <sam@inf.enst.fr>
Cc: pthreads@MIT.EDU
Subject: Re: pthreads and fork() 
In-Reply-To: Your message of "20 Feb 1996 18:34:36 +0100."
             <qw6enrpaok3.fsf@gargantua.enst.fr> 
Date: Tue, 20 Feb 1996 15:26:38 EST
From: Christopher Provenzano  <proven@MIT.EDU>


> >>>>> "Sam" == Samuel Tardieu <sam@inf.enst.fr> writes:
> 
> Sam> How is fork() supposed to work with pthreads on Linux ? Is it
> Sam> supposed to work or is there anything else which should prevent
> Sam> it to do the right job ?
> 
> I'll explain my question : a colleague of mine told me that the
> following program:
> 
> =======
> main()
> {
>         if (fork()==0) {
>                 printf("Child\n");
>                 sleep(5); 
>                 printf("End of child\n");
>         } else {
>                 printf("Father\n");
>                 sleep(5);
>                 printf("End of father\n");
>         }
> }
> =======
> 
> was never returning from the child process on Linux using a dynamic
> version of the pthreads library as bundled with the Linux GNAT
> distribution.
> 
> Could people with Linux boxes test this simple program for me and send
> me a *private* mail (I'll summarize later, don't fill up the mailing
> list) with what it did and what pthreads release you used (and
> possibly what version of the Linux libc) ?
> 
> Thanks in advance for your cooperation.
> 
>   Sam
> 
> PS/  I'm interested even if you use a static version of the pthreads
>      library.
> PPS/ The bug seems to occur only with the Linux version, I just tried
>      with SunOS and 1.60b4_1 and it works fine.
> --
> "La cervelle des petits enfants, ca doit avoir comme un petit gout de noisett
> e"
>                                                        Charles Baudelaire
> 

The sleep() call is deadlocking pthreads because pthreads assumes that 
you are going to call exec() fairly soon after calling fork() (This is
also what POSIX assumes) and has turned off all scheduling operations.

Work is under way to make  the behavior of fork() more reasonable by
tring to eliminate the scheduling deadlock problems but it is adviseable 
to still call exec() shortly after calling fork() becuase the fork() call 
will still only create a child process with the current thread running 
as per the POSIX standard. 

CAP
