Find the answer to your Linux question:
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. ...
  1. #1
    Just 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.

  2. #2
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192
    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:
    Code:
    man waitpid
    If man pages are not installed on your system, google this:
    Code:
    linux man waitpid
    Hope this helps.
    --
    Bill

    Old age and treachery will overcome youth and skill.

  3. #3
    Just Joined!
    Join Date
    Jun 2008
    Posts
    2
    As I looked at the man page.
    If I used the waidpid function like this:
    waitpid(p->pid, &status, WNOHANG | WUNTRACED);
    Do you think it would work for my case by using WNOHANG | WUNTRACED flag ?

  4. #4
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...