Dave Korn wrote:
Well... that requires editing every single printf in the whole
program, no?
It might be easier to just at the start of main() open the first
three file
descriptors, so that 0, 1 and 2 are allocated. If you open 0 from
/dev/null
in read mode and open 1 and 2 for write to /dev/null, all your stdio
should
behave sensibly. Then if you decide you want the printfs after all,
you can
just change the open to point to a real file and bingo! Instant log
file!
Here's an even better solution:
stdin = fopen("/dev/null", "r");
stdout = fopen("/dev/null", "w");
stderr = fopen("/dev/null", "w");
And then use fprintf on the respective file pointer, this ensures that
any output will go to /dev/null, even if the file descriptors don't
start at 0, which can happen (think library constructors).
Bob.
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/