mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
LibCore: Make Process::wait_for_termination return exit code
Some checks are pending
CI / Lagom (false, NO_FUZZ, macos-15, macOS, Clang) (push) Waiting to run
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Push notes / build (push) Waiting to run
Some checks are pending
CI / Lagom (false, NO_FUZZ, macos-15, macOS, Clang) (push) Waiting to run
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Push notes / build (push) Waiting to run
This commit is contained in:
parent
3468a83e45
commit
866609c682
Notes:
github-actions[bot]
2024-11-19 22:28:23 +00:00
Author: https://github.com/stasoid Commit: https://github.com/LadybirdBrowser/ladybird/commit/866609c682e Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2377 Reviewed-by: https://github.com/ADKaster ✅
3 changed files with 8 additions and 9 deletions
|
@ -335,19 +335,19 @@ ErrorOr<void> Process::disown()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorOr<bool> Process::wait_for_termination()
|
ErrorOr<int> Process::wait_for_termination()
|
||||||
{
|
{
|
||||||
VERIFY(m_pid > 0);
|
VERIFY(m_pid > 0);
|
||||||
|
|
||||||
bool exited_with_code_0 = true;
|
int exit_code = -1;
|
||||||
int status;
|
int status;
|
||||||
if (waitpid(m_pid, &status, 0) == -1)
|
if (waitpid(m_pid, &status, 0) == -1)
|
||||||
return Error::from_syscall("waitpid"sv, errno);
|
return Error::from_syscall("waitpid"sv, errno);
|
||||||
|
|
||||||
if (WIFEXITED(status)) {
|
if (WIFEXITED(status)) {
|
||||||
exited_with_code_0 &= WEXITSTATUS(status) == 0;
|
exit_code = WEXITSTATUS(status);
|
||||||
} else if (WIFSIGNALED(status)) {
|
} else if (WIFSIGNALED(status)) {
|
||||||
exited_with_code_0 = false;
|
exit_code = 128 + WTERMSIG(status);
|
||||||
} else if (WIFSTOPPED(status)) {
|
} else if (WIFSTOPPED(status)) {
|
||||||
// This is only possible if the child process is being traced by us.
|
// This is only possible if the child process is being traced by us.
|
||||||
VERIFY_NOT_REACHED();
|
VERIFY_NOT_REACHED();
|
||||||
|
@ -356,7 +356,7 @@ ErrorOr<bool> Process::wait_for_termination()
|
||||||
}
|
}
|
||||||
|
|
||||||
m_should_disown = false;
|
m_should_disown = false;
|
||||||
return exited_with_code_0;
|
return exit_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,8 +79,7 @@ public:
|
||||||
ErrorOr<void> disown();
|
ErrorOr<void> disown();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// FIXME: Make it return an exit code.
|
ErrorOr<int> wait_for_termination();
|
||||||
ErrorOr<bool> wait_for_termination();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#ifndef AK_OS_WINDOWS
|
#ifndef AK_OS_WINDOWS
|
||||||
|
|
|
@ -146,7 +146,7 @@ pid_t Process::pid() const
|
||||||
return GetProcessId(m_handle);
|
return GetProcessId(m_handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorOr<bool> Process::wait_for_termination()
|
ErrorOr<int> Process::wait_for_termination()
|
||||||
{
|
{
|
||||||
auto result = WaitForSingleObject(m_handle, INFINITE);
|
auto result = WaitForSingleObject(m_handle, INFINITE);
|
||||||
if (result == WAIT_FAILED)
|
if (result == WAIT_FAILED)
|
||||||
|
@ -156,7 +156,7 @@ ErrorOr<bool> Process::wait_for_termination()
|
||||||
if (!GetExitCodeProcess(m_handle, &exit_code))
|
if (!GetExitCodeProcess(m_handle, &exit_code))
|
||||||
return Error::from_windows_error(GetLastError());
|
return Error::from_windows_error(GetLastError());
|
||||||
|
|
||||||
return !exit_code;
|
return exit_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue