summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSage Weil <sage@inktank.com>2013-05-31 21:23:45 -0700
committerSage Weil <sage@inktank.com>2013-06-06 13:55:44 -0700
commit4bf75015ae7539a9dbabbbfc0c784dbd58aa6004 (patch)
tree351568a94ebd9c62bef02d1cb79df6f97e38b753
parentd398a1850d5895ad409f5229f0dc06651c3d4d75 (diff)
downloadceph-4bf75015ae7539a9dbabbbfc0c784dbd58aa6004.tar.gz
mon: fix preforker exit behavior behavior
In 3c5706163b72245768958155d767abf561e6d96d we made exit() not actually exit so that the leak checking would behave for a non-forking case. That is only needed for the normal exit case; every other case expects exit() to actually terminate and not continue execution. Instead, make a signal_exit() method that signals the parent (if any) and then lets you return. exit() goes back to it's usual behavior, fixing the many other calls in main(). Backport: cuttlefish Signed-off-by: Sage Weil <sage@inktank.com> Reviewed-by: Joao Eduardo Luis <joao.luis@inktank.com> (cherry picked from commit 92d085f7fd6224ffe5b7651c1f83b093f964b5cd)
-rw-r--r--src/ceph_mon.cc3
-rw-r--r--src/common/Preforker.h6
2 files changed, 7 insertions, 2 deletions
diff --git a/src/ceph_mon.cc b/src/ceph_mon.cc
index 5e820df90f2..a70db47b351 100644
--- a/src/ceph_mon.cc
+++ b/src/ceph_mon.cc
@@ -545,6 +545,7 @@ int main(int argc, const char **argv)
dout(0) << "ceph-mon: gmon.out should be in " << s << dendl;
}
- return prefork.exit(0);
+ prefork.signal_exit(0);
+ return 0;
}
diff --git a/src/common/Preforker.h b/src/common/Preforker.h
index bf76e189146..20e8b00be15 100644
--- a/src/common/Preforker.h
+++ b/src/common/Preforker.h
@@ -76,13 +76,17 @@ public:
return r;
}
- int exit(int r) {
+ int signal_exit(int r) {
if (forked) {
// tell parent
(void)::write(fd[1], &r, sizeof(r));
}
return r;
}
+ void exit(int r) {
+ signal_exit(r);
+ exit(r);
+ }
void daemonize() {
assert(forked);