From: Timo Sirainen Date: Sat, 25 Oct 2008 12:17:46 +0000 (+0300) Subject: master: Don't print "last died with error .." for fatals that were from forked child... X-Git-Tag: 1.2.alpha4~166 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3839f925645b1ecfb2e321d1741b63526a27d590;p=thirdparty%2Fdovecot%2Fcore.git master: Don't print "last died with error .." for fatals that were from forked child processes. --HG-- branch : HEAD --- diff --git a/src/master/main.c b/src/master/main.c index 62d93b8e17..74313d78da 100644 --- a/src/master/main.c +++ b/src/master/main.c @@ -35,6 +35,7 @@ #define FATAL_FILENAME "master-fatal.lastlog" static const char *configfile = SYSCONFDIR "/" PACKAGE ".conf"; +static pid_t master_original_pid; struct ioloop *ioloop; int null_fd = -1, inetd_login_fd; @@ -56,14 +57,18 @@ master_fatal_callback(enum log_type type, int status, va_list args2; int fd; - /* write the error message to a file */ - path = t_strconcat(set->base_dir, "/"FATAL_FILENAME, NULL); - fd = open(path, O_CREAT | O_TRUNC | O_WRONLY, 0600); - if (fd != -1) { - VA_COPY(args2, args); - str = t_strdup_vprintf(format, args2); - write_full(fd, str, strlen(str)); - (void)close(fd); + /* if we already forked a child process, this isn't fatal for the + main process and there's no need to write the fatal file. */ + if (getpid() == master_original_pid) { + /* write the error message to a file */ + path = t_strconcat(set->base_dir, "/"FATAL_FILENAME, NULL); + fd = open(path, O_CREAT | O_TRUNC | O_WRONLY, 0600); + if (fd != -1) { + VA_COPY(args2, args); + str = t_strdup_vprintf(format, args2); + write_full(fd, str, strlen(str)); + (void)close(fd); + } } /* write it to log as well */ @@ -577,6 +582,7 @@ int main(int argc, char *argv[]) auth_warning_print(settings_root); if (!foreground) daemonize(settings_root->defaults); + master_original_pid = getpid(); ioloop = io_loop_create();