wait for the child process from other process

wait for the child process from other process

Post by cc » Sun, 19 Jan 2003 00:12:48



Hi there,
    Can I wait for the child process from other process and get the status
in SUN, AIX and HP?
 
 
 

wait for the child process from other process

Post by Rainer Temm » Sun, 19 Jan 2003 01:01:27



> Hi there,
>     Can I wait for the child process from other process and get the status
> in SUN, AIX and HP?

Hi cc,

No Unix, that I know, would allow you to do this.

If a process forks of a child process, it becomes the parent-process
  of this new process. If this parent terminates, before the child
terminates,
  the child is "adopted by" the init process (pid==1).

So either the original parent-process (or init/pid==1) will have the
  ability to call wait()/waitpid() to examine the child-processes exitcode.
  (And init will only be able to do this, if the original parent
dies/terminates)

You can however check, if a certain process exists (kill() with signo==0).
  But the only thing you'll know from this is "a process with a certain pid
exists"
  or "a process with this pid doesn't exist" ... not more than this.

Regards ... Rainer

 
 
 

wait for the child process from other process

Post by Shaun Clowe » Tue, 21 Jan 2003 12:31:47


Quote:>     Can I wait for the child process from other process and get the status
> in SUN, AIX and HP?

You can if you use the de* interface (ptrace or procfs) though this
comes will all sorts of baggage. You don't want to do this unless you REALLY
have to.

Cheers,
Shaun

 
 
 

wait for the child process from other process

Post by cc » Tue, 21 Jan 2003 23:51:51


Im trying to implement the recovery routine, if the parent dies, I want the
start up another process and will able to wait for all the children from the
dead parent, is it possible? and How? TIA.


Quote:

> >     Can I wait for the child process from other process and get the
status
> > in SUN, AIX and HP?

> You can if you use the de* interface (ptrace or procfs) though this
> comes will all sorts of baggage. You don't want to do this unless you
REALLY
> have to.

> Cheers,
> Shaun

 
 
 

wait for the child process from other process

Post by Shaun Clowe » Thu, 23 Jan 2003 06:40:27


Quote:> Im trying to implement the recovery routine, if the parent dies, I want
the
> start up another process and will able to wait for all the children from
the
> dead parent, is it possible? and How? TIA.

You'll probably want to implement this using process groups. Have all of
your processes (including the parent process) in a process group, have one
of the child processes occasionally check to see if the parent is still
around (using kill(pid, 0) for example), if the parent process goes down the
child can spawn a new parent and that parent simply needs to continually
wait on an process in the process group to die.

There is plenty of documentation on process groups in most unix programming
books, if you need more help with this, let me know.

Cheers,
Shaun

 
 
 

1. Child Process Waiting for Parent Process

Hello Everybody:

If I want to make a UNIX child process wait until its parent exits
before the child
process proceeds with what it needs to do, is there any other way than
using
condition variables in shared memory which is the general way of
synchronizing
unrelated processes? By other way I mean something similar to the
waitpid()
API but applies in the reverse direction? After all, this case qualifies
as trying
to synchronize two related processes.

Thanks in advance for any information!

Bob

2. Modem sharing

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

4. misterious timestamp changes in syslog

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

6. help: get time in SunOS-kernel

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

8. Can I pass an array into system( ) ?

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

10. How to wait for two(or more) children in parent process?

11. child wait process hangs my outgoing emails

12. ??? How do I wait for a non-child process completion?