Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kill saving thread with SIGABRT #10908

Merged
merged 1 commit into from
Jan 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions kit/Kit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,11 @@ static LokHookFunction2* initFunction = nullptr;
class BackgroundSaveWatchdog
{
public:
BackgroundSaveWatchdog(unsigned mobileAppDocId)
BackgroundSaveWatchdog(unsigned mobileAppDocId, int savingTid)
: _saveCompleted(false)
, _watchdogThread(
// mobileAppDocId is on the stack, so capture it by value.
[mobileAppDocId, this]()
[mobileAppDocId, savingTid, this]()
{
Util::setThreadName("kitbgsv_" + Util::encodeId(mobileAppDocId, 3) + "_wdg");

Expand All @@ -201,7 +201,7 @@ class BackgroundSaveWatchdog
LOG_WRN("BgSave timed out and will self-destroy");
Log::shutdown(); // Flush logs.
// raise(3) will exit the current thread, not the process.
::kill(0, SIGKILL); // kill(2) is trapped by seccomp.
Util::killThreadById(savingTid, SIGABRT);
}
})
{
Expand Down Expand Up @@ -1487,7 +1487,7 @@ bool Document::forkToSave(const std::function<void()> &childSave, int viewId)
Util::sleepFromEnvIfSet("KitBackgroundSave", "SLEEPBACKGROUNDFORDEBUGGER");

assert(!BgSaveWatchdog && "Unexpected to have BackgroundSaveWatchdog instance");
BgSaveWatchdog = std::make_unique<BackgroundSaveWatchdog>(_mobileAppDocId);
BgSaveWatchdog = std::make_unique<BackgroundSaveWatchdog>(_mobileAppDocId, Util::getThreadId());

UnitKit::get().postBackgroundSaveFork();

Expand Down
Loading