mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-07 21:59:54 +00:00
LibWebView: Check the actual Ladybird process exit code on Windows
Even if the process has died, OpenProcess returns a non-null handle (unless some error occurred). We need to check the exit code.
This commit is contained in:
parent
6f0d7f1caf
commit
9ff75f442b
Notes:
github-actions[bot]
2025-11-04 00:30:35 +00:00
Author: https://github.com/trflynn89
Commit: 9ff75f442b
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6682
1 changed files with 12 additions and 1 deletions
|
|
@ -81,15 +81,26 @@ ErrorOr<Optional<pid_t>> Process::get_process_pid(StringView process_name, Strin
|
|||
TRY(Core::System::unlink(pid_path));
|
||||
return OptionalNone {};
|
||||
}
|
||||
|
||||
bool const process_not_found = [&pid]() {
|
||||
#if defined(AK_OS_WINDOWS)
|
||||
HANDLE process_handle = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, FALSE, *pid);
|
||||
if (process_handle == nullptr)
|
||||
return true;
|
||||
|
||||
// FIXME: We should create an RAII wrapper around HANDLE objects.
|
||||
ScopeGuard handle_guard = [&process_handle] { CloseHandle(process_handle); };
|
||||
return process_handle == nullptr;
|
||||
DWORD exit_code = 0;
|
||||
|
||||
if (GetExitCodeProcess(process_handle, &exit_code) == 0)
|
||||
return true;
|
||||
|
||||
return exit_code != STILL_ACTIVE;
|
||||
#else
|
||||
return kill(*pid, 0) < 0;
|
||||
#endif
|
||||
}();
|
||||
|
||||
if (process_not_found) {
|
||||
warnln("{} PID file '{}' exists with PID {}, but process cannot be found", process_name, pid_path, *pid);
|
||||
TRY(Core::System::unlink(pid_path));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue