00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055 #ifndef APR_THREAD_PROC_H
00056 #define APR_THREAD_PROC_H
00057
00063 #include "apr.h"
00064 #include "apr_file_io.h"
00065 #include "apr_pools.h"
00066 #include "apr_errno.h"
00067
00068 #if APR_HAVE_STRUCT_RLIMIT
00069 #include <sys/time.h>
00070 #include <sys/resource.h>
00071 #endif
00072
00073 #ifdef __cplusplus
00074 extern "C" {
00075 #endif
00076
00083 typedef enum {
00084 APR_SHELLCMD,
00085 APR_PROGRAM,
00086 APR_PROGRAM_ENV,
00087 APR_PROGRAM_PATH
00088 } apr_cmdtype_e;
00089
00090 typedef enum {
00091 APR_WAIT,
00092 APR_NOWAIT
00093 } apr_wait_how_e;
00094
00095
00096
00097
00098
00099
00100 typedef enum {
00101 APR_PROC_EXIT = 1,
00102 APR_PROC_SIGNAL = 2,
00103 APR_PROC_SIGNAL_CORE = 4
00104 } apr_exit_why_e;
00105
00107 #define APR_PROC_CHECK_EXIT(x) (x & APR_PROC_EXIT)
00108
00109 #define APR_PROC_CHECK_SIGNALED(x) (x & APR_PROC_SIGNAL)
00110
00111 #define APR_PROC_CHECK_CORE_DUMP(x) (x & APR_PROC_SIGNAL_CORE)
00112
00114 #define APR_NO_PIPE 0
00115
00117 #define APR_FULL_BLOCK 1
00118
00119 #define APR_FULL_NONBLOCK 2
00120
00121 #define APR_PARENT_BLOCK 3
00122
00123 #define APR_CHILD_BLOCK 4
00124
00126 #define APR_LIMIT_CPU 0
00127
00128 #define APR_LIMIT_MEM 1
00129
00130 #define APR_LIMIT_NPROC 2
00131
00132 #define APR_LIMIT_NOFILE 3
00133
00138 #define APR_OC_REASON_DEATH 0
00140 #define APR_OC_REASON_UNWRITABLE 1
00141 #define APR_OC_REASON_RESTART 2
00145 #define APR_OC_REASON_UNREGISTER 3
00148 #define APR_OC_REASON_LOST 4
00150 #define APR_OC_REASON_RUNNING 5
00157 typedef struct apr_proc_t {
00158
00159 pid_t pid;
00161 apr_file_t *in;
00163 apr_file_t *out;
00165 apr_file_t *err;
00166 #if APR_HAS_PROC_INVOKED || defined(DOXYGEN)
00167
00174 char *invoked;
00175 #endif
00176 #if defined(WIN32) || defined(DOXYGEN)
00177
00183 HANDLE hproc;
00184 #endif
00185 } apr_proc_t;
00186
00197 typedef void (apr_child_errfn_t)(apr_pool_t *proc, apr_status_t err,
00198 const char *description);
00199
00201 typedef struct apr_thread_t apr_thread_t;
00202
00204 typedef struct apr_threadattr_t apr_threadattr_t;
00205
00207 typedef struct apr_procattr_t apr_procattr_t;
00208
00210 typedef struct apr_thread_once_t apr_thread_once_t;
00211
00213 typedef struct apr_threadkey_t apr_threadkey_t;
00214
00216 typedef struct apr_other_child_rec_t apr_other_child_rec_t;
00217
00221 typedef void *(APR_THREAD_FUNC *apr_thread_start_t)(apr_thread_t*, void*);
00222
00223 typedef enum {
00224 APR_KILL_NEVER,
00225 APR_KILL_ALWAYS,
00226 APR_KILL_AFTER_TIMEOUT,
00227 APR_JUST_WAIT,
00228 APR_KILL_ONLY_ONCE
00229 } apr_kill_conditions_e;
00230
00231
00232
00233 #if APR_HAS_THREADS
00234
00240 APR_DECLARE(apr_status_t) apr_threadattr_create(apr_threadattr_t **new_attr,
00241 apr_pool_t *cont);
00242
00248 APR_DECLARE(apr_status_t) apr_threadattr_detach_set(apr_threadattr_t *attr,
00249 apr_int32_t on);
00250
00255 APR_DECLARE(apr_status_t) apr_threadattr_detach_get(apr_threadattr_t *attr);
00256
00265 APR_DECLARE(apr_status_t) apr_thread_create(apr_thread_t **new_thread,
00266 apr_threadattr_t *attr,
00267 apr_thread_start_t func,
00268 void *data, apr_pool_t *cont);
00269
00275 APR_DECLARE(apr_status_t) apr_thread_exit(apr_thread_t *thd,
00276 apr_status_t retval);
00277
00283 APR_DECLARE(apr_status_t) apr_thread_join(apr_status_t *retval,
00284 apr_thread_t *thd);
00285
00289 APR_DECLARE(void) apr_thread_yield(void);
00290
00297 APR_DECLARE(apr_status_t) apr_thread_once_init(apr_thread_once_t **control,
00298 apr_pool_t *p);
00299
00309 APR_DECLARE(apr_status_t) apr_thread_once(apr_thread_once_t *control,
00310 void (*func)(void));
00311
00316 APR_DECLARE(apr_status_t) apr_thread_detach(apr_thread_t *thd);
00317
00324 APR_DECLARE(apr_status_t) apr_thread_data_get(void **data, const char *key,
00325 apr_thread_t *thread);
00326
00334 APR_DECLARE(apr_status_t) apr_thread_data_set(void *data, const char *key,
00335 apr_status_t (*cleanup) (void *),
00336 apr_thread_t *thread);
00337
00344 APR_DECLARE(apr_status_t) apr_threadkey_private_create(apr_threadkey_t **key,
00345 void (*dest)(void *),
00346 apr_pool_t *cont);
00347
00353 APR_DECLARE(apr_status_t) apr_threadkey_private_get(void **new_mem,
00354 apr_threadkey_t *key);
00355
00361 APR_DECLARE(apr_status_t) apr_threadkey_private_set(void *priv,
00362 apr_threadkey_t *key);
00363
00368 APR_DECLARE(apr_status_t) apr_threadkey_private_delete(apr_threadkey_t *key);
00369
00376 APR_DECLARE(apr_status_t) apr_threadkey_data_get(void **data, const char *key,
00377 apr_threadkey_t *threadkey);
00378
00386 APR_DECLARE(apr_status_t) apr_threadkey_data_set(void *data, const char *key,
00387 apr_status_t (*cleanup) (void *),
00388 apr_threadkey_t *threadkey);
00389
00390 #endif
00391
00397 APR_DECLARE(apr_status_t) apr_procattr_create(apr_procattr_t **new_attr,
00398 apr_pool_t *cont);
00399
00408 APR_DECLARE(apr_status_t) apr_procattr_io_set(apr_procattr_t *attr,
00409 apr_int32_t in, apr_int32_t out,
00410 apr_int32_t err);
00411
00424 APR_DECLARE(apr_status_t) apr_procattr_child_in_set(struct apr_procattr_t *attr,
00425 apr_file_t *child_in,
00426 apr_file_t *parent_in);
00427
00438 APR_DECLARE(apr_status_t) apr_procattr_child_out_set(struct apr_procattr_t *attr,
00439 apr_file_t *child_out,
00440 apr_file_t *parent_out);
00441
00452 APR_DECLARE(apr_status_t) apr_procattr_child_err_set(struct apr_procattr_t *attr,
00453 apr_file_t *child_err,
00454 apr_file_t *parent_err);
00455
00463 APR_DECLARE(apr_status_t) apr_procattr_dir_set(apr_procattr_t *attr,
00464 const char *dir);
00465
00477 APR_DECLARE(apr_status_t) apr_procattr_cmdtype_set(apr_procattr_t *attr,
00478 apr_cmdtype_e cmd);
00479
00485 APR_DECLARE(apr_status_t) apr_procattr_detach_set(apr_procattr_t *attr,
00486 apr_int32_t detach);
00487
00488 #if APR_HAVE_STRUCT_RLIMIT
00489
00501 APR_DECLARE(apr_status_t) apr_procattr_limit_set(apr_procattr_t *attr,
00502 apr_int32_t what,
00503 struct rlimit *limit);
00504 #endif
00505
00517 APR_DECLARE(apr_status_t) apr_procattr_child_errfn_set(apr_procattr_t *attr,
00518 apr_child_errfn_t *errfn);
00519
00532 APR_DECLARE(apr_status_t) apr_procattr_error_check_set(apr_procattr_t *attr,
00533 apr_int32_t chk);
00534
00535 #if APR_HAS_FORK
00536
00542 APR_DECLARE(apr_status_t) apr_proc_fork(apr_proc_t *proc, apr_pool_t *cont);
00543 #endif
00544
00559 APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new_proc,
00560 const char *progname,
00561 const char * const *args,
00562 const char * const *env,
00563 apr_procattr_t *attr,
00564 apr_pool_t *cont);
00565
00592 APR_DECLARE(apr_status_t) apr_proc_wait(apr_proc_t *proc,
00593 int *exitcode, apr_exit_why_e *exitwhy,
00594 apr_wait_how_e waithow);
00595
00622 APR_DECLARE(apr_status_t) apr_proc_wait_all_procs(apr_proc_t *proc,
00623 int *exitcode,
00624 apr_exit_why_e *exitwhy,
00625 apr_wait_how_e waithow,
00626 apr_pool_t *p);
00627
00628 #define APR_PROC_DETACH_FOREGROUND 0
00629 #define APR_PROC_DETACH_DAEMONIZE 1
00637 APR_DECLARE(apr_status_t) apr_proc_detach(int daemonize);
00638
00656 APR_DECLARE(void) apr_proc_other_child_register(apr_proc_t *proc,
00657 void (*maintenance) (int reason,
00658 void *,
00659 int status),
00660 void *data, apr_file_t *write_fd,
00661 apr_pool_t *p);
00662
00672 APR_DECLARE(void) apr_proc_other_child_unregister(void *data);
00673
00694 APR_DECLARE(apr_status_t) apr_proc_other_child_alert(apr_proc_t *proc,
00695 int reason,
00696 int status);
00697
00705 APR_DECLARE(void) apr_proc_other_child_refresh(apr_other_child_rec_t *ocr,
00706 int reason);
00707
00714 APR_DECLARE(void) apr_proc_other_child_refresh_all(int reason);
00715
00722 APR_DECLARE(void) apr_proc_other_child_check(void);
00723
00727 APR_DECLARE(apr_status_t) apr_proc_other_child_read(apr_proc_t *proc, int status);
00728
00729
00735 APR_DECLARE(apr_status_t) apr_proc_kill(apr_proc_t *proc, int sig);
00736
00750 APR_DECLARE(void) apr_pool_note_subprocess(apr_pool_t *a, apr_proc_t *proc,
00751 apr_kill_conditions_e how);
00752
00753 #if APR_HAS_THREADS
00754
00755 #if (APR_HAVE_SIGWAIT || APR_HAVE_SIGSUSPEND) && !defined(OS2)
00756
00761 APR_DECLARE(apr_status_t) apr_setup_signal_thread(void);
00762
00770 APR_DECLARE(apr_status_t) apr_signal_thread(int(*signal_handler)(int signum));
00771
00772 #endif
00773
00778 APR_POOL_DECLARE_ACCESSOR(thread);
00779
00780 #endif
00781
00784 #ifdef __cplusplus
00785 }
00786 #endif
00787
00788 #endif
00789