UNIX Socket FAQ

A forum for questions and answers about network programming on Linux and all other Unix-like systems

You are not logged in.

  • Index
  • » C
  • » counting number of clients that exited

#1 2007-03-19 01:53 PM

vijraj
Member
Registered: 2006-10-23
Posts: 23

Re: counting number of clients that exited

Hi all!

I am running a while loop and creating processes by using fork() command.
I want to exit the loop when no more processes are running.
How can I achieve this.Is there a way for the main process to count the number of childs exited.
Thanks in advance.

Offline

#2 2007-03-19 03:23 PM

yurec
Member
From: Singapore
Registered: 2006-11-16
Posts: 134

Re: counting number of clients that exited

Maybe you can use a semaphore for example

Offline

#3 2007-03-19 03:56 PM

i3839
Oddministrator
From: Amsterdam
Registered: 2003-06-07
Posts: 2,239

Re: counting number of clients that exited

It seems simpler to install a signal handler for SIGCHLD, which calls wait(), and do the exited childs counting there.

Offline

  • Index
  • » C
  • » counting number of clients that exited

Board footer

Powered by FluxBB