diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2017-08-11 13:05:28 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2017-08-11 13:05:28 +0000 |
commit | b71d32d82fe540d2a9c41e8b68bf09679b8f796c (patch) | |
tree | c29bbbd2c2730a9982c5f5a9da17c2a54f96cf05 /configd | |
parent | 273a3b5e1d754ad6ca321488a761b0dcb7df48d9 (diff) |
Dump the stack if some processes will not shut down.
Diffstat (limited to 'configd')
-rw-r--r-- | configd/src/apps/sentinel/service.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/configd/src/apps/sentinel/service.cpp b/configd/src/apps/sentinel/service.cpp index 78aa618f01f..a41553735c2 100644 --- a/configd/src/apps/sentinel/service.cpp +++ b/configd/src/apps/sentinel/service.cpp @@ -18,6 +18,19 @@ extern sig_atomic_t stop; namespace config { namespace sentinel { +namespace { + +std::string getTempDir() { + const char * configuredTmp = getenv("TMP"); + if (configuredTmp) { + return configuredTmp; + } + std::string tmp = getenv("ROOT"); + tmp += "/tmp"; + return tmp; +} + +} Service::Service(const SentinelConfig::Service& service, const SentinelConfig::Application& application, std::list<OutputConnection *> &ocs, StartMetrics &metrics) @@ -99,6 +112,13 @@ Service::terminate(bool catchable) return ret; } else { setState(KILLING); + char pstackCmd[256]; + LOG(info, "%s:%d failed to stop. Will dump the stack", name().c_str(), _pid); + snprintf(pstackCmd, sizeof(pstackCmd), "pstack %d > %s/%s.pstack.%d", _pid, getTempDir().c_str(), name().c_str(), _pid); + int pstackRet = system(pstackCmd); + if (pstackRet != 0) { + LOG(warning, "'%s' failed with return value %d", pstackCmd, pstackRet); + } kill(_pid, SIGCONT); // if it was stopped for some reason int ret = kill(_pid, SIGKILL); LOG(debug, "%s: kill -SIGKILL %d: %s", name().c_str(), (int)_pid, |