mirror of
https://github.com/apache/httpd.git
synced 2025-08-03 16:33:59 +00:00
Remove unixd_detach function, because it is provided by APR as ap_detach.
This also modifies the ap_detach function to look like unixd_detach. Finally all calls to unixd_detach are changed to ap_detach. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@85635 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@ -77,78 +77,6 @@
|
||||
|
||||
unixd_config_rec unixd_config;
|
||||
|
||||
void unixd_detach(void)
|
||||
{
|
||||
int x;
|
||||
pid_t pgrp;
|
||||
|
||||
chdir("/");
|
||||
#if !defined(MPE) && !defined(OS2) && !defined(TPF)
|
||||
/* Don't detach for MPE because child processes can't survive the death of
|
||||
the parent. */
|
||||
if ((x = fork()) > 0)
|
||||
exit(0);
|
||||
else if (x == -1) {
|
||||
perror("fork");
|
||||
ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
|
||||
"%s: unable to fork new process", ap_server_argv0);
|
||||
exit(1);
|
||||
}
|
||||
RAISE_SIGSTOP(DETACH);
|
||||
#endif
|
||||
#ifdef HAVE_SETSID
|
||||
if ((pgrp = setsid()) == -1) {
|
||||
perror("setsid");
|
||||
ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
|
||||
"%s: setsid failed", ap_server_argv0);
|
||||
exit(1);
|
||||
}
|
||||
#elif defined(NEXT) || defined(NEWSOS)
|
||||
if (setpgrp(0, getpid()) == -1 || (pgrp = getpgrp(0)) == -1) {
|
||||
perror("setpgrp");
|
||||
ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
|
||||
"%s: setpgrp or getpgrp failed", ap_server_argv0);
|
||||
exit(1);
|
||||
}
|
||||
#elif defined(OS2) || defined(TPF)
|
||||
/* OS/2 and TPF don't support process group IDs */
|
||||
pgrp = getpid();
|
||||
#elif defined(MPE)
|
||||
/* MPE uses negative pid for process group */
|
||||
pgrp = -getpid();
|
||||
#else
|
||||
if ((pgrp = setpgrp(getpid(), 0)) == -1) {
|
||||
perror("setpgrp");
|
||||
ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
|
||||
"%s: setpgrp failed", ap_server_argv0);
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* close out the standard file descriptors */
|
||||
if (freopen("/dev/null", "r", stdin) == NULL) {
|
||||
char buf[120];
|
||||
ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
|
||||
"%s: unable to replace stdin with /dev/null: %s",
|
||||
ap_server_argv0, ap_strerror(errno, buf, sizeof(buf)));
|
||||
/* continue anyhow -- note we can't close out descriptor 0 because we
|
||||
* have nothing to replace it with, and if we didn't have a descriptor
|
||||
* 0 the next file would be created with that value ... leading to
|
||||
* havoc.
|
||||
*/
|
||||
}
|
||||
if (freopen("/dev/null", "w", stdout) == NULL) {
|
||||
char buf[120];
|
||||
ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
|
||||
"%s: unable to replace stdout with /dev/null: %s",
|
||||
ap_server_argv0, ap_strerror(errno, buf, sizeof(buf)));
|
||||
}
|
||||
/* stderr is a tricky one, we really want it to be the error_log,
|
||||
* but we haven't opened that yet. So leave it alone for now and it'll
|
||||
* be reopened moments later.
|
||||
*/
|
||||
}
|
||||
|
||||
/* Set group privileges.
|
||||
*
|
||||
* Note that we use the username as set in the config files, rather than
|
||||
|
@ -83,7 +83,6 @@ typedef struct {
|
||||
} unixd_config_rec;
|
||||
extern unixd_config_rec unixd_config;
|
||||
|
||||
void unixd_detach(void);
|
||||
int unixd_setup_child(void);
|
||||
void unixd_pre_config(void);
|
||||
const char *unixd_set_user(cmd_parms *cmd, void *dummy, const char *arg);
|
||||
|
@ -1231,7 +1231,7 @@ static void dexter_pre_config(ap_pool_t *p, ap_pool_t *plog, ap_pool_t *ptemp)
|
||||
is_graceful = 0;
|
||||
|
||||
if (!one_process) {
|
||||
unixd_detach();
|
||||
ap_detach();
|
||||
}
|
||||
|
||||
my_pid = getpid();
|
||||
|
@ -1261,7 +1261,7 @@ static void mpmt_pthread_pre_config(ap_pool_t *pconf, ap_pool_t *plog, ap_pool_t
|
||||
is_graceful = 0;
|
||||
|
||||
if (!one_process) {
|
||||
unixd_detach();
|
||||
ap_detach();
|
||||
}
|
||||
ap_my_pid = getpid();
|
||||
}
|
||||
|
@ -1601,7 +1601,7 @@ static void prefork_pre_config(ap_pool_t *p, ap_pool_t *plog, ap_pool_t *ptemp)
|
||||
is_graceful = 0;
|
||||
|
||||
if (!one_process) {
|
||||
unixd_detach();
|
||||
ap_detach();
|
||||
}
|
||||
|
||||
ap_my_pid = getpid();
|
||||
|
Reference in New Issue
Block a user