Index: src/include/http_log.h =================================================================== --- src/include/http_log.h (revision 170288) +++ src/include/http_log.h (working copy) @@ -63,6 +63,7 @@ #define APLOG_MARK __FILE__,__LINE__ API_EXPORT(void) ap_open_logs (server_rec *, pool *p); +API_EXPORT(void) ap_logs_child_init(server_rec *s, pool *p); /* The two primary logging functions, ap_log_error and ap_log_rerror, * use a printf style format string to build the log message. It is Index: src/main/http_log.c =================================================================== --- src/main/http_log.c (revision 170288) +++ src/main/http_log.c (working copy) @@ -113,6 +113,44 @@ {NULL, -1}, }; +/* track pipe handles to close in child process */ +typedef struct read_handle_t { + struct read_handle_t *next; + int handle; +} read_handle_t; + +static read_handle_t *read_handles; + +/* clear_handle_list() is called when plog is cleared; at that + * point we need to forget about our old list of pipe read + * handles + */ +static void clear_handle_list(void *v) +{ + read_handles = NULL; +} + +/* remember to close this handle in the child process */ +static void close_handle_in_child(pool *p, int h) +{ + read_handle_t *new_handle; + + new_handle = ap_pcalloc(p, sizeof(read_handle_t)); + new_handle->next = read_handles; + new_handle->handle = h; + read_handles = new_handle; +} + +void ap_logs_child_init(server_rec *s, pool *p) +{ + read_handle_t *cur = read_handles; + + while (cur) { + close(cur->handle); + cur = cur->next; + } +} + static int error_log_child(void *cmd, child_info *pinfo) { /* Child process code for 'ErrorLog "|..."'; @@ -221,6 +259,9 @@ setenv("_EDC_ADD_ERRNO2", "1", 1); #endif + ap_register_cleanup(p, NULL, clear_handle_list, + ap_null_cleanup); + open_error_log(s_main, p); replace_stderr = 1; @@ -593,6 +634,7 @@ ap_unblock_alarms(); pl->pid = pid; ap_register_other_child(pid, piped_log_maintenance, pl, pl->fds[1]); + close_handle_in_child(pl->p, ap_piped_log_read_fd(pl)); return 0; } Index: src/main/http_core.c =================================================================== --- src/main/http_core.c (revision 170288) +++ src/main/http_core.c (working copy) @@ -4263,7 +4263,7 @@ NULL, /* pre-run fixups */ NULL, /* logger */ NULL, /* header parser */ - NULL, /* child_init */ + ap_logs_child_init, /* child_init */ NULL, /* child_exit */ NULL /* post_read_request */ };