aboutsummaryrefslogtreecommitdiff
path: root/threadproc/unix/proc.c
diff options
context:
space:
mode:
authorJeff Trawick <trawick@apache.org>2003-02-06 18:50:30 +0000
committerJeff Trawick <trawick@apache.org>2003-02-06 18:50:30 +0000
commit52cf46542e61ed831db35f3efda92046063e8764 (patch)
tree9ac24e21d682e1a04d2d6583e8f9d8bb3b1f442f /threadproc/unix/proc.c
parent853597c1d0a0706c2ec7e90415b0e1b8d0569f7f (diff)
downloadapr-52cf46542e61ed831db35f3efda92046063e8764.tar.gz
apr-52cf46542e61ed831db35f3efda92046063e8764.zip
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: https://svn.apache.org/repos/asf/apr/apr/trunk@64330 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'threadproc/unix/proc.c')
-rw-r--r--threadproc/unix/proc.c21
1 files changed, 21 insertions, 0 deletions
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. */
}