From 3480dc696d495803f722ea7e3a4f98d82be77f31 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 29 Apr 2010 21:12:16 -0700 Subject: [PATCH] msgr: fix sigint/term signal handler to actually quit (by chaining) --- src/msg/SimpleMessenger.cc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/msg/SimpleMessenger.cc b/src/msg/SimpleMessenger.cc index e009863ebfb..43511b9e108 100644 --- a/src/msg/SimpleMessenger.cc +++ b/src/msg/SimpleMessenger.cc @@ -2124,6 +2124,13 @@ static void remove_pid_file(int signal = 0) } } +static void handle_signal(int sig) +{ + remove_pid_file(sig); + signal(sig, SIG_DFL); + kill(getpid(), sig); +} + static void write_pid_file(int pid) { if (!g_conf.pid_file) @@ -2136,8 +2143,8 @@ static void write_pid_file(int pid) ::write(fd, buf, len); ::close(fd); - signal(SIGTERM, remove_pid_file); - signal(SIGINT, remove_pid_file); + signal(SIGTERM, handle_signal); + signal(SIGINT, handle_signal); } }