/* mod_prctl.c */

#include <unistd.h>
#include <sys/prctl.h>

#include "httpd.h"
#include "http_log.h"
#include "http_config.h"

#ifndef __linux__
#error This module is Linux-specific.
#endif

#ifndef PR_SET_DUMPABLE
#define PR_SET_DUMPABLE          4
#endif

static void prctl_child_init(server_rec *s, pool *p)
{
    if (prctl(PR_SET_DUMPABLE, 1)) {
        ap_log_error(APLOG_MARK, APLOG_ALERT, s,
                     "mod_prctl: set dumpable failed - this child will not "
                     "coredump after software errors");
    }
}

module prctl_module = {
    STANDARD_MODULE_STUFF,
    NULL,                       /* initializer */
    NULL,                       /* dir config creater */
    NULL,                       /* dir merger --- default is to override */
    NULL,                       /* server config */
    NULL,                       /* merge server config */
    NULL,                       /* command table */
    NULL,                       /* handlers */
    NULL,                       /* filename translation */
    NULL,                       /* check_user_id */
    NULL,                       /* check auth */
    NULL,                       /* check access */
    NULL,                       /* type_checker */
    NULL,                       /* fixups */
    NULL,                       /* logger */
    NULL,                       /* header parser */
    prctl_child_init,           /* child init */
    NULL,                       /* child exit */
    NULL                        /* post read request */
};
