tobold.org

correct • elegant • free

△ comp.lang.perl △

◅ Open for Read & Write? ... and FLOCK

Need help on Perl and fork() ▻

2 simple questions about fork

In article <32DBFCD0.41C6@lynx.cisti.nrc.ca>,
Pascal Houde  <houde@lynx.cisti.nrc.ca> wrote:
>When forking, how the child process knows if its parents has finished
>execution (Consider that the child is looping until its parent has
>finished execution)?

Under Unix, this is possible, but not elegant.  I suggest you look again
at your design to see if you can avoid needing to do this.

Anyway, Perl's getppid function returns the process ID of this (Perl)
process's parent.  If the parent exits, this process will be inherited
by init, which has a process ID of 1.

>                      Can we set global variables between forked
>processes?

No.  However, there are lots of ways of communicating between processes
under Unix (too many, perhaps).  Between processes that are closely
related, pipes are probably the best.

Tim.
--
Tim Goodwin   | "A language needs both intestines and guts." -- Larry Wall

Original headers:

From: tim@pipex.net (Tim Goodwin)
Newsgroups: comp.lang.perl.misc
Subject: Re: 2 simple questions about fork
Date: 15 Jan 1997 14:53:56 GMT
Organization: UUNET PIPEX
Message-ID: <5bir24$aej@join.news.pipex.net>
References: <32DBFCD0.41C6@lynx.cisti.nrc.ca>

△ comp.lang.perl △

◅ Open for Read & Write? ... and FLOCK

Need help on Perl and fork() ▻