MCPcopy Create free account
hub / github.com/apache/httpd / log_child

Function log_child

server/log.c:314–363  ·  view source on GitHub ↗

Create a child process running PROGNAME with a pipe connected to * the child's stdin. The write-end of the pipe will be placed in * *FPIN on successful return. If dummy_stderr is non-zero, the * stderr for the child will be the same as the stdout of the parent. * Otherwise the child will inherit the stderr from the parent. */

Source from the content-addressed store, hash-verified

312 * stderr for the child will be the same as the stdout of the parent.
313 * Otherwise the child will inherit the stderr from the parent. */
314static int log_child(apr_pool_t *p, const char *progname,
315 apr_file_t **fpin, apr_cmdtype_e cmdtype,
316 int dummy_stderr)
317{
318 /* Child process code for 'ErrorLog "|..."';
319 * may want a common framework for this, since I expect it will
320 * be common for other foo-loggers to want this sort of thing...
321 */
322 apr_status_t rc;
323 apr_procattr_t *procattr;
324 apr_proc_t *procnew;
325 apr_file_t *errfile;
326
327 if (((rc = apr_procattr_create(&procattr, p)) == APR_SUCCESS)
328 && ((rc = apr_procattr_dir_set(procattr,
329 ap_server_root)) == APR_SUCCESS)
330 && ((rc = apr_procattr_cmdtype_set(procattr, cmdtype)) == APR_SUCCESS)
331 && ((rc = apr_procattr_io_set(procattr,
332 APR_FULL_BLOCK,
333 APR_NO_PIPE,
334 APR_NO_PIPE)) == APR_SUCCESS)
335 && ((rc = apr_procattr_error_check_set(procattr, 1)) == APR_SUCCESS)
336 && ((rc = apr_procattr_child_errfn_set(procattr, log_child_errfn))
337 == APR_SUCCESS)) {
338 char **args;
339
340 apr_tokenize_to_argv(progname, &args, p);
341 procnew = (apr_proc_t *)apr_pcalloc(p, sizeof(*procnew));
342
343 if (dummy_stderr) {
344 if ((rc = apr_file_open_stdout(&errfile, p)) == APR_SUCCESS)
345 rc = apr_procattr_child_err_set(procattr, errfile, NULL);
346 }
347
348 if (rc == APR_SUCCESS) {
349 rc = apr_proc_create(procnew, args[0], (const char * const *)args,
350 NULL, procattr, p);
351 }
352
353 if (rc == APR_SUCCESS) {
354 apr_pool_note_subprocess(p, procnew, APR_KILL_AFTER_TIMEOUT);
355 (*fpin) = procnew->in;
356 /* read handle to pipe not kept open, so no need to call
357 * close_handle_in_child()
358 */
359 }
360 }
361
362 return rc;
363}
364
365/* Open the error log for the given server_rec. If IS_MAIN is
366 * non-zero, s is the main server. */

Callers 2

open_error_logFunction · 0.85
ap_open_piped_log_exFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected