child-process.c revision f53759c12ba7f3a80c9fe277bea4f781f862a3f1
/* Copyright (C) 2002-2007 Timo Sirainen */
#include "common.h"
#include "lib-signals.h"
#include "hash.h"
#include "env-util.h"
#include "syslog-util.h"
#include "child-process.h"
#include <unistd.h>
#include <syslog.h>
const char *process_names[PROCESS_TYPE_MAX] = {
"unknown",
"auth",
"auth-worker",
"login",
"imap",
"pop3",
"ssl-build-param",
"dict"
};
struct hash_table *processes;
{
}
{
}
{
}
void child_process_init_env(void)
{
int facility;
/* remove all environment, we don't need them */
env_clean();
/* we'll log through master process */
env_put("LOG_TO_MASTER=1");
if (settings_root == NULL ||
&facility))
#ifdef DEBUG
#endif
}
{
const char *executable, *p, **argv;
/* very simple argument splitting. */
if (*title == '\0')
else
executable = argv[0];
/* hide the path, it's ugly */
}
{
switch (status) {
case FATAL_LOGOPEN:
return "Can't open log file";
case FATAL_LOGWRITE:
return "Can't write to log file";
case FATAL_LOGERROR:
return "Internal logging error";
case FATAL_OUTOFMEM:
return "Out of memory";
case FATAL_EXEC:
return "exec() failed";
case FATAL_DEFAULT:
return NULL;
}
return NULL;
}
void *context __attr_unused__)
{
struct child_process *process;
const char *process_type_name, *msg;
enum process_type process_type;
int status;
bool abnormal_exit;
/* get the type and remove from hash */
else {
}
/* write errors to syslog */
if (status == 0) {
if (process_type == PROCESS_TYPE_UNKNOWN) {
i_error("unknown child %s exited "
}
} else if (status == 1 &&
/* kludgy. hide this failure. */
} else {
i_error("child %s (%s) returned error %d%s",
}
} else if (WIFSIGNALED(status)) {
i_error("child %s (%s) killed with signal %d",
}
}
}
i_warning("waitpid() failed: %m");
}
{
}
void child_processes_init(void)
{
}
void child_processes_deinit(void)
{
/* make sure we log if child processes died unexpectedly */
}