why is child process a negative number?

Discussion in 'Perl Misc' started by ccc31807, Apr 23, 2010.

  1. ccc31807

    ccc31807 Guest

    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
     
    ccc31807, Apr 23, 2010
    #1
    1. Advertising

  2. >>>>> "cc" == ccc31807 <> writes:

    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

    --
    Charlton Wilbur
     
    Charlton Wilbur, Apr 23, 2010
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. prem_eda
    Replies:
    5
    Views:
    8,044
    Pieter Hulshoff
    Oct 11, 2004
  2. Jeff Rodriguez
    Replies:
    23
    Views:
    1,204
    David Schwartz
    Dec 9, 2003
  3. Mr. SweatyFinger
    Replies:
    2
    Views:
    2,250
    Smokey Grindel
    Dec 2, 2006
  4. EK
    Replies:
    0
    Views:
    342
  5. Z W
    Replies:
    0
    Views:
    197
Loading...

Share This Page