diff options
author | trawick <trawick@13f79535-47bb-0310-9956-ffa450edef68> | 2003-02-06 18:50:30 +0000 |
---|---|---|
committer | trawick <trawick@13f79535-47bb-0310-9956-ffa450edef68> | 2003-02-06 18:50:30 +0000 |
commit | 6c24107afad9f9daab8e2d169158f3dfb058302e (patch) | |
tree | 9ac24e21d682e1a04d2d6583e8f9d8bb3b1f442f /threadproc | |
parent | 258b05d7442a92daf7ecd55eeb39025300b0c216 (diff) | |
download | libapr-6c24107afad9f9daab8e2d169158f3dfb058302e.tar.gz |
Allow apr_proc_create() to call an app-provided error reporting
function when apr_proc_create() fails in the new child process
after fork(). The app-provided error reporting function will only
be called on platforms where apr_proc_create() first calls
fork() to create the new process.
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@64330 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'threadproc')
-rw-r--r-- | threadproc/beos/proc.c | 6 | ||||
-rw-r--r-- | threadproc/netware/proc.c | 7 | ||||
-rw-r--r-- | threadproc/os2/proc.c | 9 | ||||
-rw-r--r-- | threadproc/unix/proc.c | 21 | ||||
-rw-r--r-- | threadproc/win32/proc.c | 7 |
5 files changed, 50 insertions, 0 deletions
diff --git a/threadproc/beos/proc.c b/threadproc/beos/proc.c index e97085581..7bfa3f77f 100644 --- a/threadproc/beos/proc.c +++ b/threadproc/beos/proc.c @@ -203,6 +203,12 @@ APR_DECLARE(apr_status_t) apr_proc_fork(apr_proc_t *proc, apr_pool_t *pool) return APR_INPARENT; } +APR_DECLARE(apr_status_t) apr_procattr_child_errfn_set(apr_procattr_t *attr, + apr_child_errfn_t *errfn) +{ + /* won't ever be called on this platform, so don't save the function pointer */ + return APR_SUCCESS; +} APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new, const char *progname, const char * const *args, diff --git a/threadproc/netware/proc.c b/threadproc/netware/proc.c index 4ca612d64..537d22e93 100644 --- a/threadproc/netware/proc.c +++ b/threadproc/netware/proc.c @@ -283,6 +283,13 @@ static apr_status_t limit_proc(apr_procattr_t *attr) return APR_SUCCESS; } +APR_DECLARE(apr_status_t) apr_procattr_child_errfn_set(apr_procattr_t *attr, + apr_child_errfn_t *errfn) +{ + /* won't ever be called on this platform, so don't save the function pointer */ + return APR_SUCCESS; +} + APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *newproc, const char *progname, const char * const *args, diff --git a/threadproc/os2/proc.c b/threadproc/os2/proc.c index 75b4237bf..7afe711fe 100644 --- a/threadproc/os2/proc.c +++ b/threadproc/os2/proc.c @@ -278,6 +278,15 @@ static char *double_quotes(apr_pool_t *pool, const char *str) +APR_DECLARE(apr_status_t) apr_procattr_child_errfn_set(apr_procattr_t *attr, + apr_child_errfn_t *errfn) +{ + /* won't ever be called on this platform, so don't save the function pointer */ + return APR_SUCCESS; +} + + + APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *proc, const char *progname, const char * const *args, const char * const *env, diff --git a/threadproc/unix/proc.c b/threadproc/unix/proc.c index 8c07e8cf9..a57f76ad1 100644 --- a/threadproc/unix/proc.c +++ b/threadproc/unix/proc.c @@ -295,6 +295,13 @@ static apr_status_t limit_proc(apr_procattr_t *attr) return APR_SUCCESS; } +APR_DECLARE(apr_status_t) apr_procattr_child_errfn_set(apr_procattr_t *attr, + apr_child_errfn_t *errfn) +{ + attr->errfn = errfn; + return APR_SUCCESS; +} + APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new, const char *progname, const char * const *args, @@ -368,11 +375,17 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new, if (attr->currdir != NULL) { if (chdir(attr->currdir) == -1) { + if (attr->errfn) { + attr->errfn(pool, errno, "change of working directory failed"); + } exit(-1); /* We have big problems, the child should exit. */ } } if ((status = limit_proc(attr)) != APR_SUCCESS) { + if (attr->errfn) { + attr->errfn(pool, errno, "setting of resource limits failed"); + } exit(-1); /* We have big problems, the child should exit. */ } @@ -422,6 +435,14 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new, execvp(progname, (char * const *)args); } + if (attr->errfn) { + char *desc; + + desc = apr_psprintf(pool, "exec of '%s' failed", + progname); + attr->errfn(pool, errno, desc); + } + exit(-1); /* if we get here, there is a problem, so exit with an * error code. */ } diff --git a/threadproc/win32/proc.c b/threadproc/win32/proc.c index aa2e4a62a..fa80a9b12 100644 --- a/threadproc/win32/proc.c +++ b/threadproc/win32/proc.c @@ -281,6 +281,13 @@ static char *apr_caret_escape_args(apr_pool_t *p, const char *str) return cmd; } +APR_DECLARE(apr_status_t) apr_procattr_child_errfn_set(apr_procattr_t *attr, + apr_child_errfn_t *errfn) +{ + /* won't ever be called on this platform, so don't save the function pointer */ + return APR_SUCCESS; +} + APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new, const char *progname, const char * const *args, |