summaryrefslogtreecommitdiffstats
path: root/kit
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2022-02-19 09:43:01 -0500
committerAshod Nakashian <Ashod@users.noreply.github.com>2022-02-24 07:38:13 -0500
commit15e600ed9da492b480f838f82938bbe88d319a5b (patch)
tree8a03bfbfe51c51b1966b214766a453de83ffb6f8 /kit
parentwsd: test: minor cleanup COOL test socket helpers (diff)
downloadonline-15e600ed9da492b480f838f82938bbe88d319a5b.tar.gz
online-15e600ed9da492b480f838f82938bbe88d319a5b.zip
wsd: exit forkit when WSD dies
This may happen due to various reasons and is most commonly observed during heavy testing. We now detect when our parent has exited and we exit forkit as well, since otherwise it would be a zombie consuming resources. Change-Id: I71de0315fe7bee419a9e7d0b564630ff75ae15eb Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
Diffstat (limited to 'kit')
-rw-r--r--kit/ForKit.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/kit/ForKit.cpp b/kit/ForKit.cpp
index 9e98ccb26c..23d8608bf1 100644
--- a/kit/ForKit.cpp
+++ b/kit/ForKit.cpp
@@ -734,7 +734,8 @@ int main(int argc, char** argv)
SigUtil::setUserSignals();
- LOG_INF("ForKit process is ready.");
+ const int parentPid = getppid();
+ LOG_INF("ForKit process is ready. Parent: " << parentPid);
while (!SigUtil::getTerminationFlag())
{
@@ -744,6 +745,13 @@ int main(int argc, char** argv)
SigUtil::checkDumpGlobalState(dump_forkit_state);
+ // When our parent exits, we are assigned a new parent (typically init).
+ if (getppid() != parentPid)
+ {
+ LOG_SFL("Parent process has died. Will exit now.");
+ break;
+ }
+
#if ENABLE_DEBUG
if (!SingleKit)
#endif