develooper Front page | perl.module-authors | Postings from November 2010

Re: What hurts you the most in Perl?

Thread Previous | Thread Next
From:
Shawn H Corey
Date:
November 26, 2010 08:31
Subject:
Re: What hurts you the most in Perl?
Message ID:
4CEFE0E0.4010808@gmail.com
On 10-11-26 11:20 AM, Todd Rinaldo wrote:
> I love the fork module. It's great how it's a drop in replacement for
> the threads module. It allows me to easily swap over to threads when I
> move code over to a machine that can use threads.
>
> I very much wish, however, that forks could get a return variable from
> the fork process like threads can. This has always frustrated me.
>
> To be honest, though, the fact that Linux forks are copy on write, takes
> much of the value out of threads as far as I'm concerned.
>

Sorry but fork(2) has been around longer than Perl.  It is not something 
new but something very, very old (that's computer old, not human old).

In Perl, fork() does return a value:

* if it fails, undef

* for the child process, zero

* for the parent, the process-ID (pid) of the child

With the child's pid returned to the parent, the parent can monitor the 
child and perform tasks on its completion.

The biggest problem with fork() is communication between the child and 
parent.  For that, you need Inter-Process Communication (IPC).  See 
`perldoc perlipc`for details.


-- 
Just my 0.00000002 million dollars worth,
   Shawn

Programming is as much about organization and communication
as it is about coding.

The secret to great software:  Fail early & often.

Eliminate software piracy:  use only FLOSS.

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About