C check before writing to closed pipe

Posted by Gary on Stack Overflow See other posts from Stack Overflow or by Gary
Published on 2010-05-04T12:34:56Z Indexed on 2010/05/04 12:38 UTC
Read the original article Hit count: 275

Filed under:
|

Is there an easy way to check if a pipe is closed before writing to it in C? I have a child and parent process, and the parent has a pipe to write to the child. However, if the child closes the pipe and the parent tries to read - I get a broken pipe error.

So how can I check to make sure I can write to the pipe, so I can handle it as an error if I can't? Thanks!

© Stack Overflow or respective owner

Related posts about c

    Related posts about pipes