Fork mystries....

Daniel Eischen deischen at freebsd.org
Sat Jun 4 00:07:25 GMT 2005


On Fri, 3 Jun 2005, Aziz Kezzou wrote:

> Hi all,
> It's probably not the right mailing list to ask but I am really
> surprised about global variable sharing in a multithreaded C
> application. If I remember well my multithreading course global
> variables are shared between threads, right ?

Uhh, fork() creates a process, not a thread.  The child
is a _copy_ of the parent; they do not share address space.
See the man page for fork.  If you want really want threads,
use threads (see man page for pthread).

-- 
DE



More information about the freebsd-hackers mailing list