mpm_unix.c revision 7184de27ec1d62a83c41cdeac0953ca9fd661e8c
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess/* Licensed to the Apache Software Foundation (ASF) under one or more
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess * contributor license agreements. See the NOTICE file distributed with
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess * this work for additional information regarding copyright ownership.
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess * The ASF licenses this file to You under the Apache License, Version 2.0
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess * (the "License"); you may not use this file except in compliance with
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess * the License. You may obtain a copy of the License at
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess * Unless required by applicable law or agreed to in writing, software
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen * distributed under the License is distributed on an "AS IS" BASIS,
2e545ce2450a9953665f701bb05350f0d3f26275nd * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen * See the License for the specific language governing permissions and
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen * limitations under the License.
af33a4994ae2ff15bc67d19ff1a7feb906745bf8rbowen/* The purpose of this file is to store the code that MOST mpm's will need
3f08db06526d6901aa08c110b5bc7dde6bc39905nd * this does not mean a function only goes into this file if every MPM needs
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess * it. It means that if a function is needed by more than one MPM, and
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess * future maintenance would be served by making the code common, then the
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess * function belongs here.
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess * This is going in src/main because it is not platform specific, it is
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess * specific to multi-process servers, but NOT to Unix. Which is why it
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess * does not belong in src/os/unix
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess/* we know core's module_index is 0 */
e655a84bbb62bb1c66993fda5e74b04feda14dc6kesstypedef enum {DO_NOTHING, SEND_SIGTERM, SEND_SIGKILL, GIVEUP} action_t;
e655a84bbb62bb1c66993fda5e74b04feda14dc6kesstypedef struct extra_process_t {
e655a84bbb62bb1c66993fda5e74b04feda14dc6kessvoid ap_register_extra_mpm_process(pid_t pid, ap_generation_t gen)
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess extra_process_t *p = (extra_process_t *)malloc(sizeof(extra_process_t));
e655a84bbb62bb1c66993fda5e74b04feda14dc6kessint ap_unregister_extra_mpm_process(pid_t pid, ap_generation_t *gen)
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess /* we don't know about any such process */
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess /* Ensure pid sanity. */
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess waitret = apr_proc_wait(&proc, &status, &why, APR_NOWAIT);
0d0ba3a410038e179b695446bb149cce6264e0abnd /* ok, now it's being annoying */
0d0ba3a410038e179b695446bb149cce6264e0abnd " still did not exit, "
0d0ba3a410038e179b695446bb149cce6264e0abnd "sending a SIGTERM",
07dc96d063d49299da433f84b5c5681da9bbdf68rbowen " still did not exit, "
af33a4994ae2ff15bc67d19ff1a7feb906745bf8rbowen "sending a SIGKILL",
0, ap_server_conf,
pid);
int not_dead_yet;
int max_daemons;
} action_table[] = {
++next_action;
not_dead_yet = 0;
for (i = 0; i < max_daemons; ++i) {
if (pid == 0) {
mpm_callback(i, 0, 0);
++not_dead_yet;
while (cur_extra) {
++not_dead_yet;
} while (not_dead_yet > 0 &&
int max_daemons;
for (i = 0; i < max_daemons; ++i) {
if (pid == 0) {
mpm_callback(i, 0, 0);
while (cur_extra) {
#ifndef HAVE_GETPGID
int status;
return APR_EINVAL;
return APR_EINVAL;
return APR_EINVAL;
return APR_EINVAL;
return errno;
return APR_EINVAL;
const char *sigdesc;
return status;
0, ap_server_conf,
return APEXIT_CHILDFATAL;
switch (signum) {
case SIGTERM:
case SIGHUP:
case AP_SIG_GRACEFUL:
case SIGKILL:
0, ap_server_conf,
0, ap_server_conf,
APR_WRITE_BLOCK, p);
return rv;
(*pod)->p = p;
return APR_SUCCESS;
return APR_SUCCESS;
return rv;
return AP_NORESTART;
return rv;
return rv;
return APR_SUCCESS;
return rv;
char *srequest;
apr_pool_t *p;
return rv;
if (!lp) {
apr_pool_destroy(p);
return rv;
apr_pool_destroy(p);
return rv;
apr_pool_destroy(p);
return rv;
return rv;
int running = 0;
const char *status;
*exit_status = 0;
otherpid);
if (running) {
if (!running) {
if (!running) {
if (!running) {
if (!running) {
const char *optarg;
if (!dash_k_arg) {
if (optarg) {
static int exception_hook_enabled;
const char *arg)
return err;
return NULL;
if (exception_hook_enabled &&
geteuid() != 0 &&
0, ap_server_conf,
return APR_SUCCESS;
#ifndef NO_USE_SIGACTION
#if defined(SA_ONESHOT)
#ifdef SIGBUS
#ifdef SIGABORT
#ifdef SIGABRT
#ifdef SIGILL
#ifdef SIGFPE
#ifdef SIGBUS
#ifdef SIGABORT
#ifdef SIGABRT
#ifdef SIGILL
#ifdef SIGFPE
return APR_SUCCESS;