Skip to content

Commit

Permalink
wsd: reap bg-save on SIGCHLD
Browse files Browse the repository at this point in the history
Change-Id: I4f2941a67fc7b3871e18c6171a6714e9d021f380
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
  • Loading branch information
Ashod committed Nov 22, 2024
1 parent 010f37b commit 04aba24
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions kit/Kit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3078,6 +3078,16 @@ void wakeCallback(void* pData)
#endif
}

extern "C"
{
[[maybe_unused]]
static void sigChildHandler(int pid)
{
// Reap the child; will log failures.
SigUtil::reapZombieChild(pid);
}
}

#ifndef BUILDING_TESTS

namespace
Expand Down Expand Up @@ -3679,6 +3689,14 @@ void lokit_main(

LOG_INF("New kit client websocket inserted.");

// Since we don't track the bg-save process,
// for example to prevent multiple parallel saves,
// we could, in principle, ignore SIGCHLD and avoid
// the problem of zombies and reaping. Unfortunately,
// ignoring SIGCHLD is not portable, according to
// man 2 sigaction. So we simply waitpid(2) on SIGCHLD.
SigUtil::setSigChildHandler(sigChildHandler);

#if !MOBILEAPP
if (bTraceStartup && LogLevel != LogLevelStartup)
{
Expand Down

0 comments on commit 04aba24

Please sign in to comment.