parent of an orphaned process

[email protected] (Madhav)
Newsgroups perl.ithreads
Message-ID <[email protected]>
hi all,

             i was doing the following program in perl

	 #!/usr/bin/perl
       2
       3 main();
       4
       5 sub main
       6 {
       7     my $id;
       8     if(($id=fork())==0)
       9     {
      10       print("in child process, id=$$!\n");
      11       sleep 5;
      12       $i=getppid;
      13
      14
      15       if(kill 0,$i)
      16       {
      17          print("signal sent\n");
      18       }
      19       else
      20       {
      21         print("parent died pid=$i\n");
      22       }
      23
      24       exit;
      25     }
      26     else{
      27             print("parent terminated\n");
      28             exit(0);
      29		}

                       note that i am taking the parent pid after the 
parent has exited. according to std unix idiom, the init process (with 
pid =1) should be the parent of the orphaned child process in this 
example. but when i executed the code, this was the output:

[madhav@madhav perl]$ perl child.pl
in child process, id=13235!
parent terminated
[madhav@madhav perl]$ parent died pid=13234

this indicates that the parent of the orphaned child process is not the 
init process as it should be. please tell me what is means. i did the 
same program in C and got the parent id as 1. cant it be the same with perl?

                                                              regards,
                                                               Madhav.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.