How to find the PID of a dead parent ?

How to find the PID of a dead parent ?

Post by E.. » Wed, 18 Mar 1992 01:46:16

I have the following problem : I have a server ( say S) which is accepting
tcp connections via sockets and spawning child processes to handle
such requests. This server is also communicating with another process (say P)
via UDP sockets and sending him information about every connection made
(i.e. a child process spawned) and every connection closed (i.e death of a
child process). So far so good. But the problem arises when this server S
gets killed somehow . How can I then inform the process P that the server S
has died ??
    Thanks for any help ...



1. How to find children PID's given parent PID?

Hi folks,

my C application launches 'xterm -e foo' commands via the usual
fork/exec way. I get back the process id of the xterm as usual.
This happens like this...

    if( !(id = fork())  ) { /* child process */
        : : : :
        if( execvp( arg_list[0], arg_list ) == -1 ){
            : : : :
    } else {
       : : : :

Given that, is there a *simple* way to determine the PID of the
children of this process, i.e the pid of 'foo' and any other
processes 'foo' generates, via system calls? The id I get from the
fork is that of the xterm. Foo spawns a 'less' so the process
chain is Xterm -> Foo -> Less. All I have is the PID of Xterm.
How can I get the PID of Foo or Less?

I know that the children will have the process id of the parent as
the parent process id (i.e. like ps shows) but how can I do it
the other way around, i.e. given the parent, to check for children,
from a C program?

I looked in the source code of, say, top and have no motivation to
do kvm_reads or anything of the sort :-). This needs to be portable
to HP-UX 9.0 and Solaris 2.4...


Spiros Triantafyllopoulos                  Kokomo, IN 46904   (317) 451-0815

Delco Electronics Corporation             "Reading, 'Rithmetic, and Readnews"

2. What a joke.

3. Getting children's PID with parent's pid?

4. How to determine which port modem is on? etc

5. NEWBIE: how to find and kill by Parent PID

6. Using IDE controller card

7. Recursive loop to find pid parent and children

8. SYSLOGD Stopped

9. finding parent pid of someelse's child

10. About PID, PPID, and how to find processes with such PID

11. How the waiting parent get the pid from the child?

12. Zombie processes with parent INIT (pid 1)

13. child's parent PID is 1 ???