On Jan 7, 2010, at 14:44 , Bas van Dijk wrote:
On Thu, Jan 7, 2010 at 5:18 PM, Bulat Ziganshin
<[email protected]> wrote:
Thursday, January 7, 2010, 6:25:34 PM, you wrote:
So now I'm confused... are these standard file handles always open
program startup or are there abnormal situations when they are
afaik, parent process may close them before executing your program,
it's used in particular for running daemons
Thanks Bulat for explaining.
POSIX actually discourages that, because it's so common for library
routines to assume they can write error messages to stderr; the
approved way to handle daemons is to open the standard file handles
on /dev/null, *not* to close them. There are systems that violate
this, however (the most "fun" one I've encountered is Applications
menu commands in Mac OS X 10.4's X11.app; bash partially works around
it, but not entirely).
So the correct thing to do is to check if they are open on startup,
and if not open /dev/null.
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [email protected]
system administrator [openafs,heimdal,too many hats] [email protected]
electrical and computer engineering, carnegie mellon university KF8NH
Haskell-Cafe mailing list