CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Hybrid View

  1. #1
    Join Date
    Jun 2009
    Posts
    1

    Angry Fork(), Waitpid(), and Pipe() problems.

    I am having some trouble with the behavior of subsequent calls of waitpid() on fork()'ed processes with stdio redirected via pipe().

    In trying to emulate "echo 12345 | grep 1" the correct output is generated, but it would appear that the grep process (via execvp) never dies, so the call to waitpid() on its pid stalls forever.

    Any ideas?

    Code @:
    http://codepad.org/iIUMh1FZ

  2. #2
    Join Date
    Oct 2005
    Location
    Minnesota, U.S.A.
    Posts
    680

    Re: Fork(), Waitpid(), and Pipe() problems.

    You need a third fork to run the echo() and grep() suimutaneously. With your code, you will hang on the waitpid() in the echo().

    -Erik

Tags for this Thread

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured