Redirecting exec output to a buffer or file

Posted by devin on Stack Overflow See other posts from Stack Overflow or by devin
Published on 2010-04-09T04:43:34Z Indexed on 2010/04/09 4:53 UTC
Read the original article Hit count: 258

Filed under:
|

I'm writing a C program where I fork(), exec(), and wait(). I'd like to take the output of the program I exec'ed to write it to file or buffer.

For example, if I exec ls I want to write file1 file2 etc to buffer/file. I don't think there is a way to read stdout, so does that mean I have to use a pipe? Is there a general procedure here that I haven't been able to find?

© Stack Overflow or respective owner

Related posts about c

    Related posts about fork