mpm_unix.c revision 5bfaaf573bacb45c1cf290ce85ecc676587e8a64
0066eddda7203f6345b56f77d146a759298dc635gryzor/* Licensed to the Apache Software Foundation (ASF) under one or more
0066eddda7203f6345b56f77d146a759298dc635gryzor * contributor license agreements. See the NOTICE file distributed with
fd9abdda70912b99b24e3bf1a38f26fde908a74cnd * this work for additional information regarding copyright ownership.
fd9abdda70912b99b24e3bf1a38f26fde908a74cnd * The ASF licenses this file to You under the Apache License, Version 2.0
fd9abdda70912b99b24e3bf1a38f26fde908a74cnd * (the "License"); you may not use this file except in compliance with
0066eddda7203f6345b56f77d146a759298dc635gryzor * the License. You may obtain a copy of the License at
96ad5d81ee4a2cc66a4ae19893efc8aa6d06fae7jailletc * Unless required by applicable law or agreed to in writing, software
0066eddda7203f6345b56f77d146a759298dc635gryzor * distributed under the License is distributed on an "AS IS" BASIS,
0066eddda7203f6345b56f77d146a759298dc635gryzor * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen * See the License for the specific language governing permissions and
2e545ce2450a9953665f701bb05350f0d3f26275nd * limitations under the License.
0066eddda7203f6345b56f77d146a759298dc635gryzor/* The purpose of this file is to store the code that MOST mpm's will need
0066eddda7203f6345b56f77d146a759298dc635gryzor * this does not mean a function only goes into this file if every MPM needs
0066eddda7203f6345b56f77d146a759298dc635gryzor * it. It means that if a function is needed by more than one MPM, and
af33a4994ae2ff15bc67d19ff1a7feb906745bf8rbowen * future maintenance would be served by making the code common, then the
3f08db06526d6901aa08c110b5bc7dde6bc39905nd * function belongs here.
0066eddda7203f6345b56f77d146a759298dc635gryzor * This is going in src/main because it is not platform specific, it is
0066eddda7203f6345b56f77d146a759298dc635gryzor * specific to multi-process servers, but NOT to Unix. Which is why it
3f08db06526d6901aa08c110b5bc7dde6bc39905nd * does not belong in src/os/unix
0066eddda7203f6345b56f77d146a759298dc635gryzor/* we know core's module_index is 0 */
fe2be2903c65e2f99f04199655ea5f97a75825d0humbedoohtypedef enum {DO_NOTHING, SEND_SIGTERM, SEND_SIGKILL, GIVEUP} action_t;
0066eddda7203f6345b56f77d146a759298dc635gryzortypedef struct extra_process_t {
0066eddda7203f6345b56f77d146a759298dc635gryzorvoid ap_register_extra_mpm_process(pid_t pid, ap_generation_t gen)
0066eddda7203f6345b56f77d146a759298dc635gryzor extra_process_t *p = (extra_process_t *)ap_malloc(sizeof(extra_process_t));
1f1b6bf13313fdd14a45e52e553d3ff28689b717coarint ap_unregister_extra_mpm_process(pid_t pid, ap_generation_t *gen)
0d0ba3a410038e179b695446bb149cce6264e0abnd /* we don't know about any such process */
727872d18412fc021f03969b8641810d8896820bhumbedoohstatic int reclaim_one_pid(pid_t pid, action_t action)
0d0ba3a410038e179b695446bb149cce6264e0abnd /* Ensure pid sanity. */
af33a4994ae2ff15bc67d19ff1a7feb906745bf8rbowen waitret = apr_proc_wait(&proc, &status, &why, APR_NOWAIT);
switch(action) {
case DO_NOTHING:
case SEND_SIGTERM:
0, ap_server_conf,
pid);
case SEND_SIGKILL:
0, ap_server_conf,
pid);
case GIVEUP:
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;