Re: fork ???
- From: Liam Quin <liam holoweb net>
- To: Sri Ramkrishna <sri aracnet com>
- Cc: Derek Simkowiak <dereks kd-dev com>,Magnus Wirström <asd mail bip net>,gnome-devel-list <gnome-devel-list gnome org>
- Subject: Re: fork ???
- Date: Fri, 14 Jul 2000 17:44:01 -0400
On Fri, Jul 14, 2000 at 02:17:01PM -0700, Sri Ramkrishna wrote:
> > Under Linux, vfork is merely an alias for fork.
> Oh yeah..I remember that! I guess if your programming for Linux it
> doesn't matter. :-)
On any modern Unix, fork() is very efficent. It does not copy
memory more than it needs to, despite the appearance that it
copies the entire parent process. Unix is *designed* for fast forking.
Howver, when using fork() in a gnome process, there are things to
remember, some of which are covered in Havoc Pennington's excellent
book... some of which you'll find in Marc Rochkind, Advanced Unix
Programming, Richard Stevens' book with the same (or similar) name,
or other places...
* reset all signals
* close open files
* reset any "atexit" handlers if you are not going to call exec
* reset any changed environment variables (this is unusual) or
use execve() and pass a new environment
In general, it's easier to do
system("command &");
then use fork();
Be especially careful if you have a signal handler that can call
any X functions -- in general, don't do this -- is the signal
might go off in the child process between the fork() and the exec().
therefore, you should ignore/unset such signals before the fork().
--
Liam Quin - Barefoot in Toronto - liam@holoweb.net - http://www.holoweb.net/
Ankh on irc.sorcery.net http://valinor.sorcery.net/
Co-author, The XML Specification Guide, Wiley, 1999
Forthcoming: The Open Source XML Database Toolkit
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]