Thread: Parent process won't continue execution

  1. #1
    Registered User
    Join Date
    Mar 2009
    Posts
    4

    Parent process won't continue execution

    Hello,

    I'm developing a concurrent client that has to send requests to n-servers. I'm using processes, forking the parent process and using pipes so the child processes can communicate with the parent.

    My current problem is that the parent won't continue creating the new children unless the last one that was spawned writes back on the pipe. Is there a way to avoid that? To make the parent continue it's execution and spawning new processes until some of them start writing back on the pipe?

    Thanks!

  2. #2
    Registered User
    Join Date
    Oct 2008
    Location
    TX
    Posts
    2,059
    use non-blocking I/O for the parent process

  3. #3
    Registered User
    Join Date
    Mar 2009
    Posts
    4
    Great, I managed to solve my previous question.

    Now I have another doubt, how can I write a struct to a pipe? Let's say this for example:

    Code:
    typedef struct{
    	int one;
    	int two;
    	int three;
    }foo;
    Any ideas?

    Thanks!

  4. #4
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    fprintf(f, "%d %d %d", foo.one,foo.two,foo.three);
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Understanding fork()
    By NuNn in forum C Programming
    Replies: 8
    Last Post: 02-27-2009, 12:09 PM
  2. Replies: 3
    Last Post: 10-15-2008, 09:24 AM
  3. process execution
    By simo_mon in forum C Programming
    Replies: 9
    Last Post: 08-03-2008, 11:30 PM
  4. Round Robin Scheduling using c.
    By eclipt in forum C Programming
    Replies: 8
    Last Post: 12-28-2005, 04:58 PM
  5. Problem using java programs within C code
    By lemania in forum Linux Programming
    Replies: 1
    Last Post: 05-08-2005, 02:02 AM