diff options
author | Jeff Trawick <trawick@apache.org> | 2003-02-07 21:02:32 +0000 |
---|---|---|
committer | Jeff Trawick <trawick@apache.org> | 2003-02-07 21:02:32 +0000 |
commit | 217169f040427eb7ab2a49db9ab508e76167250f (patch) | |
tree | 6df785b7ec3ba76bc02583b610869d58050c86cb /threadproc/unix/proc.c | |
parent | 5e91349e7cfb453047411627348aeae60dca214c (diff) | |
download | apr-217169f040427eb7ab2a49db9ab508e76167250f.tar.gz apr-217169f040427eb7ab2a49db9ab508e76167250f.zip |
add apr_procattr_error_check_set() for telling apr_proc_create() to
try to anticipate any errors that might occur after fork()
(no-op everywhere but Unix)
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@64341 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'threadproc/unix/proc.c')
-rw-r--r-- | threadproc/unix/proc.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/threadproc/unix/proc.c b/threadproc/unix/proc.c index a57f76ad1..015fe04c3 100644 --- a/threadproc/unix/proc.c +++ b/threadproc/unix/proc.c @@ -302,6 +302,13 @@ APR_DECLARE(apr_status_t) apr_procattr_child_errfn_set(apr_procattr_t *attr, return APR_SUCCESS; } +APR_DECLARE(apr_status_t) apr_procattr_error_check_set(apr_procattr_t *attr, + apr_int32_t chk) +{ + attr->errchk = chk; + return APR_SUCCESS; +} + APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new, const char *progname, const char * const *args, @@ -316,6 +323,32 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new, new->err = attr->parent_err; new->out = attr->parent_out; + if (attr->errchk) { + if (attr->currdir) { + if (access(attr->currdir, R_OK|X_OK) == -1) { + /* chdir() in child wouldn't have worked */ + return errno; + } + } + + if (attr->cmdtype == APR_PROGRAM || + attr->cmdtype == APR_PROGRAM_ENV || + *progname == '/') { + /* for both of these values of cmdtype, caller must pass + * full path, so it is easy to check; + * caller can choose to pass full path for other + * values of cmdtype + */ + if (access(progname, R_OK|X_OK) == -1) { + /* exec*() in child wouldn't have worked */ + return errno; + } + } + else { + /* todo: search PATH for progname then try to access it */ + } + } + if ((new->pid = fork()) < 0) { return errno; } |