Saturday, September 25, 2010

Why does open make my file descriptor 0?

Programmer Question

I'm working on a program that is using a pipe and forks and need to change the write end to an output file. But when I open a file the file descriptor is 0 which is usually stdin but which I think is the cause of some of my problems. Here is my code



outputfd = open("file", O_RDWR | O_CREAT | O_TRUNC) == -1)


Can someone let me know why it is 0? Or how to fix it?



Find the answer here

No comments:

Post a Comment

LinkWithin

Related Posts with Thumbnails