[OPEN-ILS-DEV] PATCH: osrfConfig.C (dropping stderr messages)

Scott McKellar mck9 at swbell.net
Fri Jun 29 10:17:12 EDT 2007


--- Bill Erickson <billserickson at gmail.com> wrote:

> I'm concerned about the fcloseall() approach.  Currently, we fork the
> applications and application worker processes before the top-level
> process
> calls daemonize().  The app processes communicate via pipes to their
> worker
> children (which is something I'd like to re-design, but I'll save
> that
> discussion for later), which, if I'm reading the man page for
> fcloseall()
> correctly, will be closed by that system call.

In the case of daemonize() I'm inclined to agree.  Since the parent
exits immediately, it doesn't need to keep any file descriptors open.
The child should properly inherit all the file descriptors.  In fact
I don't really understand why we fork at all instead of just doing a
raw setsid().  I'm sure there's a reason, but I don't know what it
is.

However the parent should probably call fflush( NULL ) before forking
to make sure that we don't flush the same data twice.  Alternatively
it could call _exit() instead of exit() in order to avoid flushing
on the way out.

Another approach is to replace daemonize() with the Linux function
daemon(), which seems to do everything we need.  Or we could
implement daemonize() by calling daemon(), perhaps in a macro.
However I don't know if daemon() is widely available in other unices.
It originated in BSD, but may not be present in the AT&T lineage.
At work I use AIX, and there is no man page for daemon.

Scott McKellar
http://home.swbell.net/mck9/ct/






More information about the Open-ils-dev mailing list