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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 * This file will include OS specific functions which are not inlineable.
19 * Any inlineable functions should be defined in os-inline.c instead.
23 #include "http_core.h"
25 #include "scoreboard.h"
31 int pipe(int fildes
[2])
38 /* fork and exec functions are not defined on
39 TPF due to the implementation of tpf_fork() */
47 int execl(const char *path
, const char *arg0
, ...)
53 int execle(const char *path
, const char *arg0
, ...)
59 int execve(const char *path
, char *const argv
[], char *const envp
[])
65 int execvp(const char *file
, char *const argv
[])
72 pid_t
os_fork(server_rec
*s
, int slot
)
74 struct tpf_fork_input fork_input
;
75 APACHE_TPF_INPUT input_parms
;
80 if (dup2(fileno(sock_fp
), STDIN_FILENO
) == -1)
81 ap_log_error(APLOG_MARK
, APLOG_CRIT
, errno
, s
,
82 "unable to replace stdin with sock device driver");
84 if (dup2(fileno(sock_fp
), STDOUT_FILENO
) == -1)
85 ap_log_error(APLOG_MARK
, APLOG_CRIT
, errno
, s
,
86 "unable to replace stdout with sock device driver");
87 input_parms
.generation
= ap_my_generation
;
88 input_parms
.scoreboard_heap
= ap_scoreboard_image
;
93 input_parms
.listeners
[count
] = lr
->fd
;
96 } while(lr
!= ap_listeners
);
98 input_parms
.slot
= slot
;
99 input_parms
.restart_time
= ap_restart_time
;
100 fork_input
.ebw_data
= &input_parms
;
101 fork_input
.program
= ap_server_argv0
;
102 fork_input
.prog_type
= TPF_FORK_NAME
;
103 fork_input
.istream
= TPF_FORK_IS_BALANCE
;
104 fork_input
.ebw_data_length
= sizeof(input_parms
);
105 fork_input
.parm_data
= "-x";
106 return tpf_fork(&fork_input
);
109 int os_check_server(char *server
) {
110 #ifndef USE_TPF_DAEMON
113 if((rv
= inetd_getServerStatus(server
)) == INETD_SERVER_STATUS_INACTIVE
)
116 current_acn
= (int *)cinfc_fast(CINFC_CMMACNUM
);
117 if(ecbp2()->ce2acn
!= *current_acn
)
124 AP_DECLARE(apr_status_t
) ap_os_create_privileged_process(
125 const request_rec
*r
,
126 apr_proc_t
*newproc
, const char *progname
,
127 const char * const *args
,
128 const char * const *env
,
129 apr_procattr_t
*attr
, apr_pool_t
*p
)
131 return apr_proc_create(newproc
, progname
, args
, env
, attr
, p
);