English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
re: We should all be forking
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2007-06-06 (17:50)
From: Shawn W. <shawnw@s...>
Subject: Re: [Caml-list] re: We should all be forking

On Jun 6, 2007, at 2:28 AM, Oliver Bandel wrote:
> vfork is only (!!!) for a fork-exec combination.
> So, be aware: do not use vfork, if you don't exec right after it!

Don't use it even then! The only functions a vfork()ed child process  
can call are an exec*() one or _exit() (And then I think only execv()  
and execve() are safe). It can't return from the function vfork() was  
called in. It can't safely modify variables.

In other words, it can't do any error handling to speak of if the  
exec fails. Sure, it's faster than a fork() (Even on a OS that does  
copy-on-right memory pages -- which most modern ones do) because you  
don't copy process table structures.... but it's way too fragile when  
something goes wrong. Which will happen, sooner or later.

Shawn W.