TG has asked for the wisdom of the Perl Monks concerning the following question:
http://www.tutorialspoint.com/perl/perl_fork.htm
From where I copied the following code snippet:
The expected output is shown above and is what I expected from reading the definition of fork.#!/usr/bin/perl $pid = fork(); if( $pid == 0 ){ print "This is child process\n"; print "Chile process is existing\n"; exit 0; } print "This is parent process and child ID is $pid\n"; print "Parent process is existing\n"; exit 0; #This will produce following result This is parent process and child ID is 16417 Parent process is existing This is child process Chile process is existing
However my code ran and gave the following output:
In other words the reverse order. This is exactly the same behavior I have been experiencing.This is child process Chile process is existing This is parent process and child ID is 16417 Parent process is existing
I am running on Linux debian with perl 5.08.08
Any help would be much appreciated.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl fork problem
by lidden (Curate) on Aug 13, 2008 at 06:26 UTC | |
by Joost (Canon) on Aug 13, 2008 at 08:41 UTC | |
|
Re: Perl fork problem
by Skeeve (Parson) on Aug 13, 2008 at 07:20 UTC | |
|
Re: Perl fork problem
by cdarke (Prior) on Aug 13, 2008 at 13:36 UTC | |
by chromatic (Archbishop) on Aug 13, 2008 at 20:39 UTC | |
|
Re: Perl fork problem
by Lawliet (Curate) on Aug 13, 2008 at 06:32 UTC |