Getting a child and child's child process-id

Getting a child and child's child process-id

Post by -*_Spikey_Tribble_ » Wed, 20 May 1992 01:37:05




> I have a program that forks, creating a child, and this child forks
> again, creating a child of its own.  Both child and sub-child continue
> running for the life of the program.

> I need for the main parent program to have the process-id of its child
> (that's easy), and the process-id of the child's child.

> The only way I can figure out how to do this is to create an unnamed
> pipe befor the first child is created, and have the child's child write
> its process-id into the pipe.

 Why not just have the parent fork twice ??? Saves a lot of trouble ...
--


#  Have you read your Book In Basic Life Education today ? You should !!  #
#  Any views I express are not necessarily those of Brighton Polytechnic  #
###################### "surivorter erutangis a ma I" ######################
 
 
 

Getting a child and child's child process-id

Post by Bruce Momji » Thu, 21 May 1992 07:07:53


:  Why not just have the parent fork twice ??? Saves a lot of trouble ...

Because the child and the child's child have to share controlling
terminals, process groups, and i/o descriptors.
--
Bruce Momjian           | 830 Blythe Avenue               | home: (215)853-3000


 
 
 

Getting a child and child's child process-id

Post by -*_Spikey_Tribble_ » Fri, 22 May 1992 02:33:48




> :  Why not just have the parent fork twice ??? Saves a lot of trouble ...
> Because the child and the child's child have to share controlling
> terminals, process groups, and i/o descriptors.

A child process inherits open file descriptors without the close-on-exec
flag set ... right ?
--


#  Have you read your Book In Basic Life Education today ? You should !!  #
#  Any views I express are not necessarily those of Brighton Polytechnic  #
###################### "surivorter erutangis a ma I" ######################
 
 
 

Getting a child and child's child process-id

Post by Chet Ram » Fri, 22 May 1992 07:17:02


Quote:>A child process inherits open file descriptors without the close-on-exec
>flag set ... right ?

I don't think so.
--
``The use of history as therapy means the corruption of history as history.''
        -- Arthur Schlesinger


 
 
 

1. Getting a child and child's child process-id

I have a program that forks, creating a child, and this child forks
again, creating a child of its own.  Both child and sub-child continue
running for the life of the program.

I need for the main parent program to have the process-id of its child
(that's easy), and the process-id of the child's child.

The only way I can figure out how to do this is to create an unnamed
pipe befor the first child is created, and have the child's child write
its process-id into the pipe.

This seems like alot of overhead for one integer to be passed.  

Is there another way?  I am running on SVr3.1.

--
Bruce Momjian           | 830 Blythe Avenue               | home: (215)853-3000

2. cern httpd compiled??

3. smail failed to reap child process: No child processes

4. Problem with xpaint

5. how to kill a child process that runs other children processes

6. ftp and umask file permissions problem.

7. child process, child program

8. Can't use some themes in E

9. How to create memory in ptraced child process w/o child source code

10. kill child and its all grad child processes?

11. how do i wait for child processes, and *their* children to finish

12. child's child redirection

13. finding all process id's and parents/children