1/* Licensed to the Apache Software Foundation (ASF) under one or more 2 * contributor license agreements. See the NOTICE file distributed with 3 * this work for additional information regarding copyright ownership. 4 * The ASF licenses this file to You under the Apache License, Version 2.0 5 * (the "License"); you may not use this file except in compliance with 6 * the License. You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17#include "apr.h" 18#include "apr_private.h" 19#include "apr_thread_proc.h" 20#include "apr_file_io.h" 21#include "apr_arch_file_io.h" 22#include "apr_perms_set.h" 23 24/* System headers required for thread/process library */ 25#if APR_HAVE_PTHREAD_H 26#include <pthread.h> 27#endif 28#ifdef HAVE_SYS_RESOURCE_H 29#include <sys/resource.h> 30#endif 31#if APR_HAVE_SIGNAL_H 32#include <signal.h> 33#endif 34#if APR_HAVE_STRING_H 35#include <string.h> 36#endif 37#if APR_HAVE_SYS_WAIT_H 38#include <sys/wait.h> 39#endif 40#if APR_HAVE_STRING_H 41#include <string.h> 42#endif 43#ifdef HAVE_SCHED_H 44#include <sched.h> 45#endif 46/* End System Headers */ 47 48 49#ifndef THREAD_PROC_H 50#define THREAD_PROC_H 51 52#define SHELL_PATH "/bin/sh" 53 54#if APR_HAS_THREADS 55 56struct apr_thread_t { 57 apr_pool_t *pool; 58 pthread_t *td; 59 void *data; 60 apr_thread_start_t func; 61 apr_status_t exitval; 62}; 63 64struct apr_threadattr_t { 65 apr_pool_t *pool; 66 pthread_attr_t attr; 67}; 68 69struct apr_threadkey_t { 70 apr_pool_t *pool; 71 pthread_key_t key; 72}; 73 74struct apr_thread_once_t { 75 pthread_once_t once; 76}; 77 78#endif 79 80typedef struct apr_procattr_pscb_t apr_procattr_pscb_t; 81struct apr_procattr_pscb_t { 82 struct apr_procattr_pscb_t *next; 83 apr_perms_setfn_t *perms_set_fn; 84 apr_fileperms_t perms; 85 const void *data; 86}; 87 88struct apr_procattr_t { 89 apr_pool_t *pool; 90 apr_file_t *parent_in; 91 apr_file_t *child_in; 92 apr_file_t *parent_out; 93 apr_file_t *child_out; 94 apr_file_t *parent_err; 95 apr_file_t *child_err; 96 char *currdir; 97 apr_int32_t cmdtype; 98 apr_int32_t detached; 99#ifdef RLIMIT_CPU 100 struct rlimit *limit_cpu; 101#endif 102#if defined (RLIMIT_DATA) || defined (RLIMIT_VMEM) || defined(RLIMIT_AS) 103 struct rlimit *limit_mem; 104#endif 105#ifdef RLIMIT_NPROC 106 struct rlimit *limit_nproc; 107#endif 108#ifdef RLIMIT_NOFILE 109 struct rlimit *limit_nofile; 110#endif 111 apr_child_errfn_t *errfn; 112 apr_int32_t errchk; 113 apr_uid_t uid; 114 apr_gid_t gid; 115 apr_procattr_pscb_t *perms_set_callbacks; 116}; 117 118#endif /* ! THREAD_PROC_H */ 119 120