"unable to start piped log program '%s': %s",
pl->program, apr_strerror(status, buf, sizeof(buf)));
rc = -1;
}
}
return rc;
}
static void piped_log_maintenance(int reason, void *data, apr_wait_t status)
{
piped_log *pl = data;
apr_status_t stats;
int mpm_state;
switch (reason) {
case apr_oc_reason_death:
case apr_oc_reason_lost:
pl->pid = null; /* in case we don't get it going again, this
* tells other logic not to try to kill it
*/
apr_proc_other_child_unregister(pl);
stats = ap_mpm_query(ap_mpmq_mpm_state, &mpm_state);
if (stats != apr_success) {
ap_log_error(aplog_mark, aplog_startup, 0, null,
"can't query mpm state; not restarting "
"piped log program '%s'",
pl->program);
}
else if (mpm_state != ap_mpmq_stopping) {
ap_log_error(aplog_mark, aplog_startup, 0, null,
"piped log program '%s' failed unexpectedly",
pl->program);
if ((stats = piped_log_spawn(pl)) != apr_success) {
/* what can we do? this could be the error log we're having
* problems opening up... */
char buf[120];
ap_log_error(aplog_mark, aplog_startup, 0, null,
"piped_log_maintenance: unable to respawn '%s': %s",
pl->program, apr_strerror(stats, buf, sizeof(buf)));
}
}
break;
case apr_oc_reason_unwritable:
/* we should not kill off the pipe here, since it may only be full.
* if it really is locked, we should kill it off manually. */
break;
case apr_oc_reason_restart:
if (pl->pid != null) {
apr_proc_kill(pl->pid, sigterm);
pl->pid = null;
}