On Fri, Nov 7, 2008 at 5:12 AM, Abhishek Kulkarni <[EMAIL PROTECTED]> wrote:
> just curious about the difference between close({0,1,2}) and fclose({stdin,
> stdout, stderr}).

if you close 0, 1, 2 then any later printf(stderr will print garbage
to an active 9p connection. That's bad.



> open("/dev/null", O_RDONLY);
> open("/dev/null", O_WRONLY); /* or dup2(0,1) */
> open("/dev/null", O_WRONLY); /* or dup2(0,2) */

well, maybe, but it means you have a bug: you're using those fd's when
you think you have daemonized. Oops.

If there are still random usages of stdio in the code these are
certainly safer. It is possibly best to redirect stdout/err to syslog.

ron

Reply via email to