trawick 2003/02/07 13:02:32
Modified: . CHANGES
include apr_thread_proc.h
include/arch/unix apr_arch_threadproc.h
threadproc/beos proc.c
threadproc/netware proc.c
threadproc/os2 proc.c
threadproc/unix proc.c
threadproc/win32 proc.c
Log:
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)
Revision Changes Path
1.376 +4 -5 apr/CHANGES
Index: CHANGES
===================================================================
RCS file: /home/cvs/apr/CHANGES,v
retrieving revision 1.375
retrieving revision 1.376
diff -u -r1.375 -r1.376
--- CHANGES 6 Feb 2003 22:54:55 -0000 1.375
+++ CHANGES 7 Feb 2003 21:02:30 -0000 1.376
@@ -8,11 +8,10 @@
.pdb symbol files.) Documentation on how-to-use these symbol files
will be forthcoming. [Allen Edwards, William Rowe]
- *) 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. [Jeff Trawick]
+ *) Add two new proc attributes to improve diagnostics for
+ apr_proc_create() failures on platforms where fork()+exec() is used.
+ See the doc for apr_procattr_child_errfn_set() and
+ apr_procattr_error_check_set(). [Jeff Trawick]
*) Rename rules.mk to apr_rules.mk and make apr_rules.mk be installed.
[Thom May]
1.92 +14 -0 apr/include/apr_thread_proc.h
Index: apr_thread_proc.h
===================================================================
RCS file: /home/cvs/apr/include/apr_thread_proc.h,v
retrieving revision 1.91
retrieving revision 1.92
diff -u -r1.91 -r1.92
--- apr_thread_proc.h 6 Feb 2003 18:50:30 -0000 1.91
+++ apr_thread_proc.h 7 Feb 2003 21:02:30 -0000 1.92
@@ -512,6 +512,20 @@
APR_DECLARE(apr_status_t) apr_procattr_child_errfn_set(apr_procattr_t *attr,
apr_child_errfn_t
*errfn);
+/**
+ * Specify that apr_proc_create() should do whatever it can to report
+ * failures to the caller of apr_proc_create(), rather than find out in
+ * the child.
+ * @param chk Flag to indicate whether or not extra work should be done
+ * to try to report failures to the caller.
+ * @remark This flag only affects apr_proc_create() on platforms where
+ * fork() is used. This leads to extra overhead in the calling
+ * process, but that may help the application handle such
+ * errors more gracefully.
+ */
+APR_DECLARE(apr_status_t) apr_procattr_error_check_set(apr_procattr_t *attr,
+ apr_int32_t chk);
+
#if APR_HAS_FORK
/**
* This is currently the only non-portable call in APR. This executes
1.5 +1 -0 apr/include/arch/unix/apr_arch_threadproc.h
Index: apr_arch_threadproc.h
===================================================================
RCS file: /home/cvs/apr/include/arch/unix/apr_arch_threadproc.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- apr_arch_threadproc.h 6 Feb 2003 18:50:30 -0000 1.4
+++ apr_arch_threadproc.h 7 Feb 2003 21:02:31 -0000 1.5
@@ -135,6 +135,7 @@
struct rlimit *limit_nofile;
#endif
apr_child_errfn_t *errfn;
+ apr_int32_t errchk;
};
#endif /* ! THREAD_PROC_H */
1.50 +7 -0 apr/threadproc/beos/proc.c
Index: proc.c
===================================================================
RCS file: /home/cvs/apr/threadproc/beos/proc.c,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -r1.49 -r1.50
--- proc.c 6 Feb 2003 18:50:30 -0000 1.49
+++ proc.c 7 Feb 2003 21:02:31 -0000 1.50
@@ -210,6 +210,13 @@
return APR_SUCCESS;
}
+APR_DECLARE(apr_status_t) apr_procattr_error_check_set(apr_procattr_t *attr,
+ apr_int32_t chk)
+{
+ /* won't ever be used on this platform, so don't save the flag */
+ return APR_SUCCESS;
+}
+
APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new, const char
*progname,
const char * const *args,
const char * const *env,
1.22 +7 -0 apr/threadproc/netware/proc.c
Index: proc.c
===================================================================
RCS file: /home/cvs/apr/threadproc/netware/proc.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- proc.c 6 Feb 2003 18:50:30 -0000 1.21
+++ proc.c 7 Feb 2003 21:02:31 -0000 1.22
@@ -290,6 +290,13 @@
return APR_SUCCESS;
}
+APR_DECLARE(apr_status_t) apr_procattr_error_check_set(apr_procattr_t *attr,
+ apr_int32_t chk)
+{
+ /* won't ever be used on this platform, so don't save the flag */
+ return APR_SUCCESS;
+}
+
APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *newproc,
const
char *progname,
const
char * const *args,
1.57 +9 -0 apr/threadproc/os2/proc.c
Index: proc.c
===================================================================
RCS file: /home/cvs/apr/threadproc/os2/proc.c,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -r1.56 -r1.57
--- proc.c 6 Feb 2003 18:50:30 -0000 1.56
+++ proc.c 7 Feb 2003 21:02:31 -0000 1.57
@@ -287,6 +287,15 @@
+APR_DECLARE(apr_status_t) apr_procattr_error_check_set(apr_procattr_t *attr,
+ apr_int32_t chk)
+{
+ /* won't ever be used on this platform, so don't save the flag */
+ 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,
1.65 +33 -0 apr/threadproc/unix/proc.c
Index: proc.c
===================================================================
RCS file: /home/cvs/apr/threadproc/unix/proc.c,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -r1.64 -r1.65
--- proc.c 6 Feb 2003 18:50:30 -0000 1.64
+++ proc.c 7 Feb 2003 21:02:31 -0000 1.65
@@ -302,6 +302,13 @@
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,
@@ -315,6 +322,32 @@
new->in = attr->parent_in;
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;
1.88 +7 -0 apr/threadproc/win32/proc.c
Index: proc.c
===================================================================
RCS file: /home/cvs/apr/threadproc/win32/proc.c,v
retrieving revision 1.87
retrieving revision 1.88
diff -u -r1.87 -r1.88
--- proc.c 6 Feb 2003 18:50:30 -0000 1.87
+++ proc.c 7 Feb 2003 21:02:32 -0000 1.88
@@ -288,6 +288,13 @@
return APR_SUCCESS;
}
+APR_DECLARE(apr_status_t) apr_procattr_error_check_set(apr_procattr_t *attr,
+ apr_int32_t chk)
+{
+ /* won't ever be used on this platform, so don't save the flag */
+ return APR_SUCCESS;
+}
+
APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new,
const char *progname,
const char * const *args,