From 79ad82ccde98391ba59dc1234c10def78520b680 Mon Sep 17 00:00:00 2001 From: Adam Megacz Date: Sun, 14 Feb 2010 17:30:42 -0800 Subject: [PATCH] Have bosserver catch SIGTERM and shut down gracefully. Many modern process supervision systems (runsv, daemontools, sysvinit) expect to be able to terminate a process gracefully by sending it a SIGTERM; although SIGQUIT is nominally used for this purpose it seems to have fallen into disuse as a matter of practice. Therefore, to integrate as smoothly as possible with the outside world, bosserver should catch SIGTERM and interpret it as a request to shut down gracefully. When used with process supervision (runsv or daemontools), the previous behavior would cause bosserver to die but leave its children running, and then bosserver would get restarted by the supervisor. The result is a situation where there would be two copies of every bnode process. Mayhem ensues. Change-Id: I8690fba0af6c2b9f9613527254af915be9e76dfc Reviewed-on: http://gerrit.openafs.org/1310 Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear --- src/bozo/bnode.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/bozo/bnode.c b/src/bozo/bnode.c index b0ba84a47..bd28b02cc 100644 --- a/src/bozo/bnode.c +++ b/src/bozo/bnode.c @@ -817,7 +817,7 @@ bnode_SoftInt(void *param) void bnode_Int(int asignal) { - if (asignal == SIGQUIT) { + if (asignal == SIGQUIT || asignal == SIGTERM) { IOMGR_SoftSig(bozo_ShutdownAndExit, (void *)(intptr_t)asignal); } else { IOMGR_SoftSig(bnode_SoftInt, (void *)(intptr_t)asignal); @@ -851,6 +851,9 @@ bnode_Init(void) if (code) return errno; code = sigaction(SIGQUIT, &newaction, NULL); + if (code) + return errno; + code = sigaction(SIGTERM, &newaction, NULL); if (code) return errno; return code; -- 2.39.5