00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef APR_THREAD_PROC_H
00018 #define APR_THREAD_PROC_H
00019
00025 #include "apr.h"
00026 #include "apr_file_io.h"
00027 #include "apr_pools.h"
00028 #include "apr_errno.h"
00029
00030 #if APR_HAVE_STRUCT_RLIMIT
00031 #include <sys/time.h>
00032 #include <sys/resource.h>
00033 #endif
00034
00035 #ifdef __cplusplus
00036 extern "C" {
00037 #endif
00038
00045 typedef enum {
00046 APR_SHELLCMD,
00047 APR_PROGRAM,
00048 APR_PROGRAM_ENV,
00049 APR_PROGRAM_PATH,
00050 APR_SHELLCMD_ENV
00053 } apr_cmdtype_e;
00054
00055 typedef enum {
00056 APR_WAIT,
00057 APR_NOWAIT
00058 } apr_wait_how_e;
00059
00060
00061
00062
00063
00064
00065 typedef enum {
00066 APR_PROC_EXIT = 1,
00067 APR_PROC_SIGNAL = 2,
00068 APR_PROC_SIGNAL_CORE = 4
00069 } apr_exit_why_e;
00070
00072 #define APR_PROC_CHECK_EXIT(x) (x & APR_PROC_EXIT)
00073
00074 #define APR_PROC_CHECK_SIGNALED(x) (x & APR_PROC_SIGNAL)
00075
00076 #define APR_PROC_CHECK_CORE_DUMP(x) (x & APR_PROC_SIGNAL_CORE)
00077
00079 #define APR_NO_PIPE 0
00080
00082 #define APR_FULL_BLOCK 1
00083
00084 #define APR_FULL_NONBLOCK 2
00085
00086 #define APR_PARENT_BLOCK 3
00087
00088 #define APR_CHILD_BLOCK 4
00089
00091 #define APR_LIMIT_CPU 0
00092
00093 #define APR_LIMIT_MEM 1
00094
00095 #define APR_LIMIT_NPROC 2
00096
00097 #define APR_LIMIT_NOFILE 3
00098
00103 #define APR_OC_REASON_DEATH 0
00105 #define APR_OC_REASON_UNWRITABLE 1
00106 #define APR_OC_REASON_RESTART 2
00110 #define APR_OC_REASON_UNREGISTER 3
00113 #define APR_OC_REASON_LOST 4
00115 #define APR_OC_REASON_RUNNING 5
00122 typedef struct apr_proc_t {
00123
00124 pid_t pid;
00126 apr_file_t *in;
00128 apr_file_t *out;
00130 apr_file_t *err;
00131 #if APR_HAS_PROC_INVOKED || defined(DOXYGEN)
00132
00139 char *invoked;
00140 #endif
00141 #if defined(WIN32) || defined(DOXYGEN)
00142
00148 HANDLE hproc;
00149 #endif
00150 } apr_proc_t;
00151
00162 typedef void (apr_child_errfn_t)(apr_pool_t *proc, apr_status_t err,
00163 const char *description);
00164
00166 typedef struct apr_thread_t apr_thread_t;
00167
00169 typedef struct apr_threadattr_t apr_threadattr_t;
00170
00172 typedef struct apr_procattr_t apr_procattr_t;
00173
00175 typedef struct apr_thread_once_t apr_thread_once_t;
00176
00178 typedef struct apr_threadkey_t apr_threadkey_t;
00179
00181 typedef struct apr_other_child_rec_t apr_other_child_rec_t;
00182
00186 typedef void *(APR_THREAD_FUNC *apr_thread_start_t)(apr_thread_t*, void*);
00187
00188 typedef enum {
00189 APR_KILL_NEVER,
00190 APR_KILL_ALWAYS,
00191 APR_KILL_AFTER_TIMEOUT,
00192 APR_JUST_WAIT,
00193 APR_KILL_ONLY_ONCE
00194 } apr_kill_conditions_e;
00195
00196
00197
00198 #if APR_HAS_THREADS
00199
00205 APR_DECLARE(apr_status_t) apr_threadattr_create(apr_threadattr_t **new_attr,
00206 apr_pool_t *cont);
00207
00213 APR_DECLARE(apr_status_t) apr_threadattr_detach_set(apr_threadattr_t *attr,
00214 apr_int32_t on);
00215
00222 APR_DECLARE(apr_status_t) apr_threadattr_detach_get(apr_threadattr_t *attr);
00223
00229 APR_DECLARE(apr_status_t) apr_threadattr_stacksize_set(apr_threadattr_t *attr,
00230 apr_size_t stacksize);
00231
00242 APR_DECLARE(apr_status_t) apr_threadattr_guardsize_set(apr_threadattr_t *attr,
00243 apr_size_t guardsize);
00244
00253 APR_DECLARE(apr_status_t) apr_thread_create(apr_thread_t **new_thread,
00254 apr_threadattr_t *attr,
00255 apr_thread_start_t func,
00256 void *data, apr_pool_t *cont);
00257
00263 APR_DECLARE(apr_status_t) apr_thread_exit(apr_thread_t *thd,
00264 apr_status_t retval);
00265
00271 APR_DECLARE(apr_status_t) apr_thread_join(apr_status_t *retval,
00272 apr_thread_t *thd);
00273
00277 APR_DECLARE(void) apr_thread_yield(void);
00278
00285 APR_DECLARE(apr_status_t) apr_thread_once_init(apr_thread_once_t **control,
00286 apr_pool_t *p);
00287
00297 APR_DECLARE(apr_status_t) apr_thread_once(apr_thread_once_t *control,
00298 void (*func)(void));
00299
00304 APR_DECLARE(apr_status_t) apr_thread_detach(apr_thread_t *thd);
00305
00312 APR_DECLARE(apr_status_t) apr_thread_data_get(void **data, const char *key,
00313 apr_thread_t *thread);
00314
00322 APR_DECLARE(apr_status_t) apr_thread_data_set(void *data, const char *key,
00323 apr_status_t (*cleanup) (void *),
00324 apr_thread_t *thread);
00325
00332 APR_DECLARE(apr_status_t) apr_threadkey_private_create(apr_threadkey_t **key,
00333 void (*dest)(void *),
00334 apr_pool_t *cont);
00335
00341 APR_DECLARE(apr_status_t) apr_threadkey_private_get(void **new_mem,
00342 apr_threadkey_t *key);
00343
00349 APR_DECLARE(apr_status_t) apr_threadkey_private_set(void *priv,
00350 apr_threadkey_t *key);
00351
00356 APR_DECLARE(apr_status_t) apr_threadkey_private_delete(apr_threadkey_t *key);
00357
00364 APR_DECLARE(apr_status_t) apr_threadkey_data_get(void **data, const char *key,
00365 apr_threadkey_t *threadkey);
00366
00374 APR_DECLARE(apr_status_t) apr_threadkey_data_set(void *data, const char *key,
00375 apr_status_t (*cleanup) (void *),
00376 apr_threadkey_t *threadkey);
00377
00378 #endif
00379
00385 APR_DECLARE(apr_status_t) apr_procattr_create(apr_procattr_t **new_attr,
00386 apr_pool_t *cont);
00387
00396 APR_DECLARE(apr_status_t) apr_procattr_io_set(apr_procattr_t *attr,
00397 apr_int32_t in, apr_int32_t out,
00398 apr_int32_t err);
00399
00412 APR_DECLARE(apr_status_t) apr_procattr_child_in_set(struct apr_procattr_t *attr,
00413 apr_file_t *child_in,
00414 apr_file_t *parent_in);
00415
00426 APR_DECLARE(apr_status_t) apr_procattr_child_out_set(struct apr_procattr_t *attr,
00427 apr_file_t *child_out,
00428 apr_file_t *parent_out);
00429
00440 APR_DECLARE(apr_status_t) apr_procattr_child_err_set(struct apr_procattr_t *attr,
00441 apr_file_t *child_err,
00442 apr_file_t *parent_err);
00443
00451 APR_DECLARE(apr_status_t) apr_procattr_dir_set(apr_procattr_t *attr,
00452 const char *dir);
00453
00465 APR_DECLARE(apr_status_t) apr_procattr_cmdtype_set(apr_procattr_t *attr,
00466 apr_cmdtype_e cmd);
00467
00473 APR_DECLARE(apr_status_t) apr_procattr_detach_set(apr_procattr_t *attr,
00474 apr_int32_t detach);
00475
00476 #if APR_HAVE_STRUCT_RLIMIT
00477
00489 APR_DECLARE(apr_status_t) apr_procattr_limit_set(apr_procattr_t *attr,
00490 apr_int32_t what,
00491 struct rlimit *limit);
00492 #endif
00493
00505 APR_DECLARE(apr_status_t) apr_procattr_child_errfn_set(apr_procattr_t *attr,
00506 apr_child_errfn_t *errfn);
00507
00520 APR_DECLARE(apr_status_t) apr_procattr_error_check_set(apr_procattr_t *attr,
00521 apr_int32_t chk);
00522
00530 APR_DECLARE(apr_status_t) apr_procattr_addrspace_set(apr_procattr_t *attr,
00531 apr_int32_t addrspace);
00532
00541 APR_DECLARE(apr_status_t) apr_procattr_user_set(apr_procattr_t *attr,
00542 const char *username,
00543 const char *password);
00544
00550 APR_DECLARE(apr_status_t) apr_procattr_group_set(apr_procattr_t *attr,
00551 const char *groupname);
00552
00553
00554 #if APR_HAS_FORK
00555
00563 APR_DECLARE(apr_status_t) apr_proc_fork(apr_proc_t *proc, apr_pool_t *cont);
00564 #endif
00565
00582 APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new_proc,
00583 const char *progname,
00584 const char * const *args,
00585 const char * const *env,
00586 apr_procattr_t *attr,
00587 apr_pool_t *pool);
00588
00615 APR_DECLARE(apr_status_t) apr_proc_wait(apr_proc_t *proc,
00616 int *exitcode, apr_exit_why_e *exitwhy,
00617 apr_wait_how_e waithow);
00618
00645 APR_DECLARE(apr_status_t) apr_proc_wait_all_procs(apr_proc_t *proc,
00646 int *exitcode,
00647 apr_exit_why_e *exitwhy,
00648 apr_wait_how_e waithow,
00649 apr_pool_t *p);
00650
00651 #define APR_PROC_DETACH_FOREGROUND 0
00652 #define APR_PROC_DETACH_DAEMONIZE 1
00660 APR_DECLARE(apr_status_t) apr_proc_detach(int daemonize);
00661
00679 APR_DECLARE(void) apr_proc_other_child_register(apr_proc_t *proc,
00680 void (*maintenance) (int reason,
00681 void *,
00682 int status),
00683 void *data, apr_file_t *write_fd,
00684 apr_pool_t *p);
00685
00695 APR_DECLARE(void) apr_proc_other_child_unregister(void *data);
00696
00717 APR_DECLARE(apr_status_t) apr_proc_other_child_alert(apr_proc_t *proc,
00718 int reason,
00719 int status);
00720
00728 APR_DECLARE(void) apr_proc_other_child_refresh(apr_other_child_rec_t *ocr,
00729 int reason);
00730
00737 APR_DECLARE(void) apr_proc_other_child_refresh_all(int reason);
00738
00744 APR_DECLARE(apr_status_t) apr_proc_kill(apr_proc_t *proc, int sig);
00745
00759 APR_DECLARE(void) apr_pool_note_subprocess(apr_pool_t *a, apr_proc_t *proc,
00760 apr_kill_conditions_e how);
00761
00762 #if APR_HAS_THREADS
00763
00764 #if (APR_HAVE_SIGWAIT || APR_HAVE_SIGSUSPEND) && !defined(OS2)
00765
00770 APR_DECLARE(apr_status_t) apr_setup_signal_thread(void);
00771
00779 APR_DECLARE(apr_status_t) apr_signal_thread(int(*signal_handler)(int signum));
00780
00781 #endif
00782
00787 APR_POOL_DECLARE_ACCESSOR(thread);
00788
00789 #endif
00790
00793 #ifdef __cplusplus
00794 }
00795 #endif
00796
00797 #endif
00798