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.