fork communication between parent & child

  • Follow


Hi,
A process forks another process and increments its(parent's) child
counter.

Only now the child knows when it's processing will be over. On childs
job completion it has to decrement the child counter held by parent.

What is the best to communicate between a parent & child process 4
synchronized update of CHILD COUNTERS.

I know it can be done via signals & IPC. I used IPC (shared mem),
because of SIGCHLD interrupt. As it was creating zombie processes.

Please put some light on this issue. 

-- Pradeep Sharma

0
Reply pradeep (2) 2/18/2005 10:37:48 AM

pradeep@mauj.com wrote:
# Hi,
# A process forks another process and increments its(parent's) child
# counter.
# 
# Only now the child knows when it's processing will be over. On childs
# job completion it has to decrement the child counter held by parent.
# 
# What is the best to communicate between a parent & child process 4
# synchronized update of CHILD COUNTERS.
# 
# I know it can be done via signals & IPC. I used IPC (shared mem),
# because of SIGCHLD interrupt. As it was creating zombie processes.

SIGCHLD tells the parent a child is waiting to return its status. The
parent still has to use one of the wait functions to get the status
and allow the child to disappear.

--
SM Ryan http://www.rawbw.com/~wyrmwif/
One of the drawbacks of being a martyr is that you have to die.
0
Reply SM 2/18/2005 11:19:10 AM


pradeep@mauj.com writes:

> Hi,
> A process forks another process and increments its(parent's) child
> counter.
> 
> Only now the child knows when it's processing will be over. On childs
> job completion it has to decrement the child counter held by parent.
> 
> What is the best to communicate between a parent & child process 4
> synchronized update of CHILD COUNTERS.
> 
> I know it can be done via signals & IPC. I used IPC (shared mem),
> because of SIGCHLD interrupt. As it was creating zombie processes.
> 
> Please put some light on this issue. 

The parent should call wait or waitpid, and when a child termination
is reported, decrement its child counter.  Note that waitpid can be
called with WNOHANG to poll.

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
Until real software engineering is developed, the next best practice
is to develop with a dynamic system that has extreme late binding in
all aspects. The first system to really do this in an important way
is Lisp. -- Alan Kay
0
Reply Pascal 2/18/2005 11:19:36 AM

2 Replies
652 Views

(page loaded in 0.062 seconds)

Similiar Articles:













7/15/2012 1:58:22 PM


Reply: