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

Scott McKellar mck9 at swbell.net
Thu Jun 28 21:27:00 EDT 2007


--- Mike Rylander <mrylander at gmail.com> wrote:

<snip>

> To that end, I propose that we forcibly close stdin, stdout and
> stderr
> inside libopensrf/utils.c:daemonize() after calling setsid().  This
> will require some more checks in the logging code to make sure that
> stderr is still around for logging, and if not ... well, like Scott
> said, the admin is a poo-poo head for not providing either a log file
> or the required syslog info, and the message will be lost.  Logging
> directly to stderr from within an opensrf application will also
> obviously do nothing in this case.

<snip>

By "more checks in the logging code" I think you mean something like
the following additions to log.c:

static int osrfStderr = 1;

void osrfStderrOff( void ) {
    osrfStderr = 0;
}

Then every write to stderr would be wrapped like this:

    if( osrfStderr ) {
        fprintf( stderr, ... )
    }

daemonize() would call osrfStderrOff() when it closes stderr.  We
could also provide a function osrfStderrOn(), for complete symmetry,
but I'm not sure that it would ever make sense to call it.

I'd submit this notion in the form of a patch, but there's another
patch still outstanding on log.c.  I want to see that one resolved
first, because it adds an fprintf() to stderr.

Alternatively there might be a way for log.c to determine whether
the process was attached to a terminal, and either write or not
write to stderr accordingly.  I don't know how that would work, nor
whether it would work at all.

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





More information about the Open-ils-dev mailing list