mpm_unix.c revision 3a59bb90be3bc6246632384c3d885b875ae507d5
74b23191c8f49798f7513f324bbdbbe32f8a1db2Razvan Pascanu/* Licensed to the Apache Software Foundation (ASF) under one or more
74b23191c8f49798f7513f324bbdbbe32f8a1db2Razvan Pascanu * contributor license agreements. See the NOTICE file distributed with
74b23191c8f49798f7513f324bbdbbe32f8a1db2Razvan Pascanu * this work for additional information regarding copyright ownership.
74b23191c8f49798f7513f324bbdbbe32f8a1db2Razvan Pascanu * The ASF licenses this file to You under the Apache License, Version 2.0
74b23191c8f49798f7513f324bbdbbe32f8a1db2Razvan Pascanu * (the "License"); you may not use this file except in compliance with
74b23191c8f49798f7513f324bbdbbe32f8a1db2Razvan Pascanu * the License. You may obtain a copy of the License at
74b23191c8f49798f7513f324bbdbbe32f8a1db2Razvan Pascanu * Unless required by applicable law or agreed to in writing, software
74b23191c8f49798f7513f324bbdbbe32f8a1db2Razvan Pascanu * distributed under the License is distributed on an "AS IS" BASIS,
74b23191c8f49798f7513f324bbdbbe32f8a1db2Razvan Pascanu * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
74b23191c8f49798f7513f324bbdbbe32f8a1db2Razvan Pascanu * See the License for the specific language governing permissions and
74b23191c8f49798f7513f324bbdbbe32f8a1db2Razvan Pascanu * limitations under the License.
74b23191c8f49798f7513f324bbdbbe32f8a1db2Razvan Pascanu/* The purpose of this file is to store the code that MOST mpm's will need
74b23191c8f49798f7513f324bbdbbe32f8a1db2Razvan Pascanu * this does not mean a function only goes into this file if every MPM needs
74b23191c8f49798f7513f324bbdbbe32f8a1db2Razvan Pascanu * it. It means that if a function is needed by more than one MPM, and
74b23191c8f49798f7513f324bbdbbe32f8a1db2Razvan Pascanu * future maintenance would be served by making the code common, then the
74b23191c8f49798f7513f324bbdbbe32f8a1db2Razvan Pascanu * function belongs here.
74b23191c8f49798f7513f324bbdbbe32f8a1db2Razvan Pascanu * This is going in src/main because it is not platform specific, it is
74b23191c8f49798f7513f324bbdbbe32f8a1db2Razvan Pascanu * specific to multi-process servers, but NOT to Unix. Which is why it
74b23191c8f49798f7513f324bbdbbe32f8a1db2Razvan Pascanu * does not belong in src/os/unix
#include "httpd.h"
#include "http_config.h"
#include "http_core.h"
#include "http_log.h"
#include "http_main.h"
#include "mpm_common.h"
#include "ap_mpm.h"
#include "ap_listen.h"
#include "scoreboard.h"
#include "util_mutex.h"
#ifdef HAVE_PWD_H
#include <pwd.h>
#ifdef HAVE_GRP_H
#include <grp.h>
#include <unistd.h>
typedef struct extra_process_t {
extras = p;
if (cur) {
if (prev) {
int status;
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;