Subject: Re: popen reentrant (was Re: SA/pthread and vfork)
To: Christian Limpach <chris@pin.lu>
From: Nathan J. Williams <nathanw@wasabisystems.com>
List: tech-kern
Date: 09/11/2003 14:07:17
Christian Limpach <chris@pin.lu> writes:

> > Isn't the simple solution, for pthreads, just equate __vfork = _sys_fork
> > in libpthread.  Any use of vfork(2) should be able to be replaced by
> > fork(2)
> > with no change in behavior.   The sharing of address space is an
> > optimization, not a communications mechanism.  Any applications that
> > breaks is broken and needs to be fixed.
> 
> not quite.  The child's libc is still configured to run threaded
> (__isthreaded set and libpthread strong aliases on many functions) and some
> functions (all/most FILE* functions for instance) can block and then run
> libpthread code.  This is why we need reentrant popen (and system) in any
> case and probably some fork wrapper which resets libc/libpthread in the
> child.

We don't have to go to very herioc efforts in this respect; a forked
child of a multithreaded process is restricted to calling
async-signal-safe functions; popen(), system() and stdio functions
aren't in that category. 

        - Nathan