Re: [dev] [surf] [patch] Close stdout after printing XID

From: Abby Cedar <>
Date: Mon, 20 Feb 2012 02:11:23 -0800 (PST)

> And so it becomes a philosophical question. When you close a file descriptor, > it's because you're not going to use it any more. If the programmer > forgets > and writes to stdout anyway, is it better to have the program exit with an > error, or to hide the problem so that nobody discovers the bug? Indeed it is. The reality is very few programmers check the return value of printf/putchar/puts anyway given that they assume stdout is always open. By using freopen, errno isn't clobbered when said programmer later tries to output to stdout which may be unexpected. So I guess the real question is which is easier to debug, an unexpected changing of errno or an obvious lack of screen output? Of course good practice is to save errno before a library call such as printf regardless but we've probably all seen code that doesn't. The sed trick you mentioned works well, thank you. But I still believe something should be done to close stdout as I'm sure surf's current behaviour is not what was intended. Either freopen or just fclose will do. -- Abby
Received on Mon Feb 20 2012 - 11:11:23 CET

This archive was generated by hypermail 2.3.0 : Mon Feb 20 2012 - 11:12:04 CET