aboutsummaryrefslogtreecommitdiff
path: root/threadproc/unix/procsup.c
diff options
context:
space:
mode:
Diffstat (limited to 'threadproc/unix/procsup.c')
-rw-r--r--threadproc/unix/procsup.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/threadproc/unix/procsup.c b/threadproc/unix/procsup.c
index b96cb48ec..391f803bd 100644
--- a/threadproc/unix/procsup.c
+++ b/threadproc/unix/procsup.c
@@ -54,24 +54,28 @@
#include "threadproc.h"
-APR_DECLARE(apr_status_t) apr_proc_detach(void)
+APR_DECLARE(apr_status_t) apr_proc_detach(int daemonize)
{
int x;
pid_t pgrp;
chdir("/");
#if !defined(MPE) && !defined(OS2) && !defined(TPF) && !defined(BEOS)
-/* 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");
- fprintf(stderr, "unable to fork new process\n");
- exit(1); /* we can't do anything here, so just exit. */
+ /* Don't detach for MPE because child processes can't survive the death of
+ * the parent. */
+ if (daemonize) {
+ if ((x = fork()) > 0) {
+ exit(0);
+ }
+ else if (x == -1) {
+ perror("fork");
+ fprintf(stderr, "unable to fork new process\n");
+ exit(1); /* we can't do anything here, so just exit. */
+ }
+ /* RAISE_SIGSTOP(DETACH); */
}
-/* RAISE_SIGSTOP(DETACH);*/
#endif
+
#ifdef HAVE_SETSID
if ((pgrp = setsid()) == -1) {
return errno;