why is child process a negative number?

C

ccc31807

On Win32, the process id is whatever the value of $$ is.

When you fork(), the parent retains whatever the original pid was.
However, the child pid has a negative number. Why?

CODE
my $orig_pid = $$;
my $child = fork();
if ($$ > 0)
{
print qq(1. The pid is $$\n);
print qq(Parent process pid is $$, child is $child\n);
}
else
{
print qq(2. The pid is $$\n);
print qq(Child process pid is $$, parent is $orig_pid\n);
}

OUTPUT
1. The pid is 3172
Parent process pid is 3172, child is -2272
2. The pid is -2272
Child process pid is -2272, parent is 3172
 
C

Charlton Wilbur

cc> On Win32, the process id is whatever the value of $$ is. When
cc> you fork(), the parent retains whatever the original pid was.
cc> However, the child pid has a negative number. Why?

Win32 is not Unix. perldoc perlfork

Charlton
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top