[Sheepdog] [PATCH v2] logger: correct crash_handler output

Liu Yuan namei.unix at gmail.com
Sat Apr 28 16:14:23 CEST 2012


From: Liu Yuan <tailai.ly at taobao.com>

'pid' is always 0 in logger process. So it is useless to
output it.

- fix logger pid output.

Signed-off-by: Liu Yuan <tailai.ly at taobao.com>
---
 lib/logger.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/logger.c b/lib/logger.c
index 05e62a0..43a8267 100644
--- a/lib/logger.c
+++ b/lib/logger.c
@@ -51,6 +51,7 @@ static char *log_name;
 static char *log_nowname;
 static int log_level = SDOG_INFO;
 static pid_t pid;
+static pid_t sheep_pid;
 static key_t semkey;
 
 static int64_t max_logsize = 500 * 1024 * 1024;  /*500MB*/
@@ -385,10 +386,10 @@ static notrace void crash_handler(int signo)
 		vprintf(SDOG_ERR, "logger pid %d segfaulted.\n",
 			getpid());
 	} else if (signo == SIGHUP) {
-		vprintf(SDOG_ERR, "sheep pid %d exited unexpectedly.\n", pid);
+		vprintf(SDOG_ERR, "sheep pid %d exited unexpectedly.\n", sheep_pid);
 	} else {
 		vprintf(SDOG_ERR, "logger pid %d got unexpected signal %d.\n",
-			pid, signo);
+			getpid(), signo);
 	}
 
 	log_flush();
@@ -410,6 +411,7 @@ notrace int log_init(char *program_name, int size, int to_stdout, int level,
 	log_nowname = outfile;
 
 	semkey = random();
+	sheep_pid = getpid();
 
 	if (!to_stdout) {
 		struct sigaction sa_old;
-- 
1.7.8.2




More information about the sheepdog mailing list