Help answer threads with 0 replies.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 05-08-2005, 03:56 PM   #1
Registered: Aug 2003
Location: kerala , India
Distribution: RH9 , FC1 ,
Posts: 141

Rep: Reputation: 15
A program which exists only after all its children have exited.. plz comment


This is just a trial to write a program in which the parent quits only after all its children have finished executin..

so heres what i did

Now i case i am talking abt here is that the parent creates all the child process and then only starts to wait for them

1) so for each process forked().. i put the pid of that process into a list.
2) after creating the process the parent waits all children have exited..
the code for this is something like this

wait_list is the list to which the pids are added
Addtolist() adds a value pid to the wait_list
RemovefromList () removes the node with value pid from the wait_list



switch ( pid = fork ())
case -1 : perror("fork");
case 0:
execl( ........ );

printf("starting executing of process with pid.. %d",pid);

while(wait_list!=(List *)0)

pid = waitpid(0,&wait_val,__WALL);
if(pid == -1)
//printf("do we reach here..\n");

switch ( pid ){
case 0: //printf("no child exited..\n");

default: //i.e somechild has exited. so remove child from wait_list
printf("process with pid - %d exited..removing from list\n",pid);


One questions about this piece of code

Sometimes in waitpid() call .. it gives an error and prints out... "No Child Processes "

But in each case i tried all child processes had finished execution before this error came... does anyone know why?


Old 05-08-2005, 03:59 PM   #2
Registered: Aug 2003
Location: kerala , India
Distribution: RH9 , FC1 ,
Posts: 141

Original Poster
Rep: Reputation: 15
Sorry abt the heading.... its

" A program which exits only after all its children have exited.."

Can this be edited in the forum page anyway????

thnks and sorry



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
screen shooting program plz einstien Linux - Software 6 07-16-2012 09:05 AM
To find which all services depend on a particular service... a method ..plz comment tuxfood Red Hat 1 06-15-2005 10:47 PM
SIOCADDRT: File exists SIOCCADDRT: File Exists Failed to bring up eth0. opsraja Linux - Networking 0 01-10-2005 08:29 AM
Exists a DC++ like program for Linux? zWaR Linux - Newbie 4 12-27-2003 12:52 PM
program 4 autistic children???? Felipe78 Linux - Software 5 12-25-2003 03:00 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:21 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration