Results 1 to 4 of 4
Hi folks,
I got a question here:
I create a server that listen to several clients connect to the server at the same time or within certain short time period. ...
- 06-11-2008 #1Just Joined!
- Join Date
- Jun 2008
- Posts
- 2
Problem on dealing with Server's Parent and child Process

Hi folks,
I got a question here:
I create a server that listen to several clients connect to the server at the same time or within certain short time period. So I have several child processes to handle them separately. And create pipe for each child process that let them able send msg to parent process. Meanwhile, in the parent process, I want to create a linked list for connections that connected server. when one child process terminated. I ll move it from the list.
The thing I got confused at is how can I runing the server continuously that I can generate the new element to end of the list and listen to the child process . which means I do not need to wait for the child process terminated . I can move on to do other things.
I hope I did explain the question clearly. Thanks , really need help on the process and child thing. too confusing at this moment.
- 06-12-2008 #2
If I understand you correctly, you're trying to find a way to detect whether a child process has finished, without having the parent process hang until that moment arrives.
Do this at the command line:
If man pages are not installed on your system, google this:Code:man waitpid
Hope this helps.Code:linux man waitpid
--
Bill
Old age and treachery will overcome youth and skill.
- 06-12-2008 #3Just Joined!
- Join Date
- Jun 2008
- Posts
- 2
As I looked at the man page.
If I used the waidpid function like this:
Do you think it would work for my case by using WNOHANG | WUNTRACED flag ?waitpid(p->pid, &status, WNOHANG | WUNTRACED);
- 06-12-2008 #4
Unless you're anticipating someone sending the SIGSTOP signal to one of your child processes, you don't particularly need the WUNTRACED option. If you're going to use the WUNTRACED option, be prepared to handle processes that are still alive but just stopped.
Other than that, it should work.--
Bill
Old age and treachery will overcome youth and skill.


Reply With Quote