fuzzyping has asked for the wisdom of the Perl Monks concerning the following question:
And the results:#!/usr/bin/perl use strict; my $pid = fork(); die "Can't fork: $!" unless defined $pid; if ($pid > 0) { print "I'm the parent and my pid is $$. My child is $pid\n"; } else { print "I'm the child and my pid is $$. My parent is " . getpp +id() . "\n"; }
Thanks,$ while true; do perl fork.pl; sleep 1; done I'm the parent and my pid is 2094. My child is 2095 I'm the child and my pid is 2095. My parent is 1 I'm the parent and my pid is 2097. My child is 2098 I'm the child and my pid is 2098. My parent is 1 I'm the parent and my pid is 2100. My child is 2101 I'm the child and my pid is 2101. My parent is 1 I'm the parent and my pid is 2103. My child is 2104 I'm the child and my pid is 2104. My parent is 2103 I'm the parent and my pid is 2106. My child is 2107 I'm the child and my pid is 2107. My parent is 1 ^C
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Broken getppid() on Darwin/OSX
by Eimi Metamorphoumai (Deacon) on Aug 01, 2004 at 20:09 UTC | |
by fuzzyping (Chaplain) on Aug 01, 2004 at 20:12 UTC | |
by Eimi Metamorphoumai (Deacon) on Aug 02, 2004 at 13:08 UTC | |
|
Re: Broken getppid() on Darwin/OSX
by Zaxo (Archbishop) on Aug 01, 2004 at 20:14 UTC | |
|
Re: Broken getppid() on Darwin/OSX
by superfrink (Curate) on Aug 01, 2004 at 21:20 UTC |