changeset 8323:60c48789841b HEAD

master: Don't print "last died with error .." for fatals that were from forked child processes.
author Timo Sirainen <tss@iki.fi>
date Sat, 25 Oct 2008 15:17:46 +0300
parents 66a792567e59
children 66e0eaf4d536
files src/master/main.c
diffstat 1 files changed, 14 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/master/main.c	Fri Oct 24 22:10:37 2008 +0300
+++ b/src/master/main.c	Sat Oct 25 15:17:46 2008 +0300
@@ -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 @@
 	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 @@
 	auth_warning_print(settings_root);
 	if (!foreground)
 		daemonize(settings_root->defaults);
+	master_original_pid = getpid();
 
 	ioloop = io_loop_create();