in reply to getppid is broken in Win?

The reason getppid isn't usually implemented under Windows is that it is trying to find what process id the operating system thinks is the parent of your process. Windows doesn't have a parent-child relationship between processes, so there is no real meaning to the result of getppid.

There is a rather technical discussion of finding the process that started the current process here but note that Window's conception of the process that started a child process does not change when the parent process dies. In Unix systems, child processes whose parent processes die become children of process id 1, the "init" process. In Windows, they don't.

What you probably need to do is to back up a step and think about what you are going to use the parent process id for. You may be able to just save the value of $$ before the fork. The child process can then use the saved id to find its parent.

By the way, in the message "Parent process..." you should put child=$child. Putting parentid=$child is confusing.

Try this:

#!/usr/bin/perl use strict; use warnings; my $parent_pid=$$; print "pid=$$\n"; my $child= fork(); die "Can't fork: $!" unless defined $child; if ($child != 0) { #parent process print "Parent process:Pid=$$,child=$child\n"; } else { # child process print "Child process: Pid=$$,parent=$parent_pid\n"; }