Re: Strange behaviour with printf vs. g_print (Repost)



On Tue, 20 Aug 2002, Tristan Van Berkom wrote:

That was one of the first things I checked out;
its as if stdout->_fileno was closed or redirected or
I lost connection with my terminal.

Weird!

The application is a daemon but thats just

fork(); twice
setsid(0);

Both Stevens and my man page say that setsid() doesn't take any
parameters.

and
close(stdin->_fileno);

but the problem could also be with the usage of libmysqlclient
(which involves alot of text streaming to and from the "mysqld")

There's still no obvious way that should stop printf() from working...

Oh, wait.  When you call setsid() your process will no longer have a
controlling terminal...

Stevens, pp. 244-247 + chapter 13.  You should still be able to open a log
file and fprintf() to that or use syslog.

Changing the current directory to the root may also be prudent (the
current directory may be a mounted directory that suddenly disappears --
or that the operator would really, really like to umount, but can't
because of the daemon).

-Peter

"...they may well attempt to treat the gangrene they got when blowing off
their foot by amputating their leg with a shotgun!"




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]