X-Git-Url: https://git.exim.org/exim.git/blobdiff_plain/cf73943b330a44b8716aa1fcbf649ee1f0fbc67b..7be682ca5ebd9571a01b762195b11c34cd231830:/src/src/daemon.c diff --git a/src/src/daemon.c b/src/src/daemon.c index 777cda6f4..27b4cb265 100644 --- a/src/src/daemon.c +++ b/src/src/daemon.c @@ -1,10 +1,8 @@ -/* $Cambridge: exim/src/src/daemon.c,v 1.26 2008/12/12 14:44:25 nm4 Exp $ */ - /************************************************* * Exim - an Internet mail transport agent * *************************************************/ -/* Copyright (c) University of Cambridge 1995 - 2007 */ +/* Copyright (c) University of Cambridge 1995 - 2009 */ /* See the file NOTICE for conditions of use and distribution. */ /* Functions concerned with running Exim as a daemon */ @@ -31,8 +29,8 @@ static smtp_slot empty_smtp_slot = { 0, NULL }; * Local static variables * *************************************************/ -static volatile BOOL sigchld_seen; -static volatile BOOL sighup_seen; +static SIGNAL_BOOL sigchld_seen; +static SIGNAL_BOOL sighup_seen; static int accept_retry_count = 0; static int accept_retry_errno; @@ -425,6 +423,13 @@ if (pid == 0) for (i = 0; i < listen_socket_count; i++) (void)close(listen_sockets[i]); + /* Set FD_CLOEXEC on the SMTP socket. We don't want any rogue child processes + to be able to communicate with them, under any circumstances. */ + (void)fcntl(accept_socket, F_SETFD, + fcntl(accept_socket, F_GETFD) | FD_CLOEXEC); + (void)fcntl(dup_accept_socket, F_SETFD, + fcntl(dup_accept_socket, F_GETFD) | FD_CLOEXEC); + #ifdef SA_NOCLDWAIT act.sa_handler = SIG_IGN; sigemptyset(&(act.sa_mask)); @@ -823,8 +828,17 @@ pid_t pid; while ((pid = waitpid(-1, &status, WNOHANG)) > 0) { int i; - DEBUG(D_any) debug_printf("child %d ended: status=0x%x\n", (int)pid, - status); + DEBUG(D_any) + { + debug_printf("child %d ended: status=0x%x\n", (int)pid, status); +#ifdef WCOREDUMP + if (WIFEXITED(status)) + debug_printf(" normal exit, %d\n", WEXITSTATUS(status)); + else if (WIFSIGNALED(status)) + debug_printf(" signal exit, signal %d%s\n", WTERMSIG(status), + WCOREDUMP(status) ? " (core dumped)" : ""); +#endif + } /* If it's a listening daemon for which we are keeping track of individual subprocesses, deal with an accepting process that has terminated. */