Children of fork() Cannot pthread_create()?

Rob Landley rob at landley.net
Thu Jun 7 16:14:58 UTC 2007


On Wednesday 06 June 2007 4:19 pm, David Daney wrote:
> Daniel Jacobowitz wrote:
> > On Wed, Jun 06, 2007 at 01:04:09PM -0700, David Daney wrote:
> >> Yes, pthread_create is not on the list of functions that can be called 
> >> after a fork (but before exec).
> >>
> >> The list of functions is near the end of this document:
> >>
> >> 
http://www.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_04.html

That's about signal handling.

> > There's no restriction on what you can do after fork; you may be
> > thinking of vfork or no-MMU?
> > 
> From: http://www.opengroup.org/onlinepubs/009695399/functions/fork.html
> 
> .
> .
> .
> When a programmer is writing a multi-threaded program, the first 
> described use of fork(), creating new threads in the same program, is 
> provided by the pthread_create() function. The fork() function is thus 
> used only to run new programs, and the effects of calling functions that 
> require certain resources between the call to fork() and the call to an 
> exec function are undefined.

Possibly it's getting confused about who the process group leader is?  (man 2 
setpgid)  A while back I was trying to figure out how the terminal control 
stuff worked to implement toysh (man tcsetpgrp) and reading the kernel source 
to see what it was doing with these syscalls I kept running into 
_thread_groups_, and I never figured out what the relationship between thread 
groups and process groups was...

Rob
-- 
The Google cluster became self-aware at 2:14am EDT August 29, 2007...



More information about the uClibc mailing list