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

Function piped_log_spawn

server/log.c:1773–1824  ·  view source on GitHub ↗

Spawn the piped logger process pl->program. */

Source from the content-addressed store, hash-verified

1771
1772/* Spawn the piped logger process pl->program. */
1773static apr_status_t piped_log_spawn(piped_log *pl)
1774{
1775 apr_procattr_t *procattr;
1776 apr_proc_t *procnew = NULL;
1777 apr_status_t status;
1778
1779 if (((status = apr_procattr_create(&procattr, pl->p)) != APR_SUCCESS) ||
1780 ((status = apr_procattr_dir_set(procattr, ap_server_root))
1781 != APR_SUCCESS) ||
1782 ((status = apr_procattr_cmdtype_set(procattr, pl->cmdtype))
1783 != APR_SUCCESS) ||
1784 ((status = apr_procattr_child_in_set(procattr,
1785 pl->read_fd,
1786 pl->write_fd))
1787 != APR_SUCCESS) ||
1788 ((status = apr_procattr_child_errfn_set(procattr, log_child_errfn))
1789 != APR_SUCCESS) ||
1790 ((status = apr_procattr_error_check_set(procattr, 1)) != APR_SUCCESS)) {
1791 /* Something bad happened, give up and go away. */
1792 ap_log_error(APLOG_MARK, APLOG_STARTUP, status, ap_server_conf, APLOGNO(00103)
1793 "piped_log_spawn: unable to setup child process '%s'",
1794 pl->program);
1795 }
1796 else {
1797 char **args;
1798
1799 apr_tokenize_to_argv(pl->program, &args, pl->p);
1800 procnew = apr_pcalloc(pl->p, sizeof(apr_proc_t));
1801 status = apr_proc_create(procnew, args[0], (const char * const *) args,
1802 NULL, procattr, pl->p);
1803
1804 if (status == APR_SUCCESS) {
1805 pl->pid = procnew;
1806 /* procnew->in was dup2'd from pl->write_fd;
1807 * since the original fd is still valid, close the copy to
1808 * avoid a leak. */
1809 apr_file_close(procnew->in);
1810 procnew->in = NULL;
1811 apr_proc_other_child_register(procnew, piped_log_maintenance, pl,
1812 pl->write_fd, pl->p);
1813 close_handle_in_child(pl->p, pl->read_fd);
1814 }
1815 else {
1816 /* Something bad happened, give up and go away. */
1817 ap_log_error(APLOG_MARK, APLOG_STARTUP, status, ap_server_conf, APLOGNO(00104)
1818 "unable to start piped log program '%s'",
1819 pl->program);
1820 }
1821 }
1822
1823 return status;
1824}
1825
1826
1827static void piped_log_maintenance(int reason, void *data, apr_wait_t status)

Callers 2

piped_log_maintenanceFunction · 0.85
ap_open_piped_log_exFunction · 0.85

Calls 2

close_handle_in_childFunction · 0.85
ap_log_errorFunction · 0.50

Tested by

no test coverage detected