473,569 Members | 2,984 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How does a parent know if one if its children finished executing?

78 New Member
Hello guys.
This time, i need to implement waitpid in order to know if one of the children of a parent has finished executing. The assignment requires me to run a limited number of child processes. Then if max is reached and one more is asked to run by the user from the command line, the parent must wait and see if there is a free spot. (in the array of children)
Now i know i have to use waitpid somewhere, but using it as: wait child1, waitchild2....w ill wait for all. I need to wait for 1. The thing is the child will excute another program, meaning it will replace all the code after fork(). So i have no control over the communication between the parent and child, i.e. if i say x = execvp(), this will only be executed in the child, so the parent can't know the return value inorder to check for return values to find a free spot.

Now the solution i've come up with is by forking 2 times for each child, one for the child to run in, and another for parallelly executing waitpid until this child exits, and notifying the parent. I haven't implemented this yet, i just want to know if i'm way off the normal solution path.

Thanks guys.
Apr 4 '07 #1
1 1561
Sebouh
78 New Member
It turns out i WAS far from the right path.
My method was too complicated and less effective then using a simple wait(&status).
Damn it! I've wasted my time trying my method, while the answer was right there. Stupid!
Apr 4 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
1804
by: Dhruv | last post by:
I'd like to know if anyone had some sort of code like parent_ptr that I could use. Let me just describe what I'm looking for. It's kinda a hybrid between auto_ptr, and shared_ptr. You can specify who is the parent of the object pointed to. Then, only the parent object can give someone the parent-ship, and it itself relinquishes ownership, so...
9
2064
by: jon wayne | last post by:
OK! I had this nagging doubt Consider (without worrying abt access specifiers) class Kid : public Parent{...}; Parent::someFunc() { Kid k; }
2
5291
by: dannielum | last post by:
Hi all, I am trying to write a Binary Search Tree that each of its node will have 3 node pointers: left, right and parent. I need a parent pointer for some the purpose of my project. Without the pointer to the parent node, the program will be inefficient and slow. It works fine at first. However, when I started to build the remove function,...
0
2886
by: Walt Borders | last post by:
Hi, My problem: Merging two datasets deletes parent elements, preserves all children. I've created two dataSets. Each use the same schema, parent-child nested tables. The first dataSet is loaded with historical data read from an XML file. The second dataSet has current data filled from a dataGrid.
0
2207
by: Karthick Kumar | last post by:
Hi, I need to create a simple parent/child hierarchical menu. I have alread used the Treeview control but my requirement is slightly different than the Treeview control. I already have the kind of menu I am talking about, written in Classic ASP, but I need to write the entire menu thing in Asp.Net using CSharp. I have a Sql table which...
6
9412
by: Edwinah63 | last post by:
Hi everyone, could someone give me some thoughts on the best way to manage mdi parent and child forms? in vb6 i could scroll through the forms collection and determine which forms were open/closed and their current state. now i can't. before i didn't have to declare numerous named instances each time i loaded or unloaded a form.
10
19595
by: Goran Djuranovic | last post by:
Hi all, Does anyone know how to declare a variable in a class to be accessible ONLY from a classes instantiated within that class? For example: ************* CODE ***************** Public Class Parent '*** HOW TO DECLARE IT *** Dim Age As String = "1/1/2000"
1
2765
by: Hexman | last post by:
Hello All, What I'm trying to do is update a child record using a parent-child relation. I want to find out if it is faster than than doing multiple selects. Anyways, I've created a dataset (ds), have 2 datatables (dtRC and dtST). Created the parent-child relationship with multiple columns and added the relation to the dataset. Now what...
3
293
by: xmail123 | last post by:
Why does this code work? I am new to C# and have been studying this piece of code. It loops through an Adjacency Matrix table to populate a tree view. I have two questions about why this code works. 1. initTreeView(TreeNode N) creates a new "temp" table to hold the children for each node. Each time the table is created it has the same...
0
7703
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7930
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
6290
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5514
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5228
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3662
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2118
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1229
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
950
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.