First, contrary to what you might be used to elsewhere, posting code here works best if it's in <code> tags.
#!/usr/bin/perl
#print "PID=$$\n";
my $child=fork();
die "Can't fork:$!" unless defined $child;
if($child>0) {
print "Parent process:PID=$$, child=$child\n";
}
else {
my $ppid=getppid();
print "Child process: PID=$$,parent=$ppid\n";
}
The reason this doesn't work for you, basically, is you're on Windows. On that platform, fork is faked using threads (and getppid is not implemented). This probably also means that signals won't work the way I'd otherwise expect them to, so my previous advice won't help much either. My experience with Perl on Windows is minimal, so I don't think I'll be able to help you with this at all. |