mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-04 15:19:42 +00:00
LibCore: Port Process to Windows
Windows doesn't have a concept of zombie children, hence: * `disown` not needed * we need a process handle because otherwise if the process have ended by the time `wait_for_termination` is called its pid may be reassigned to other process
This commit is contained in:
parent
4a731b3858
commit
3468a83e45
Notes:
github-actions[bot]
2024-11-19 22:28:29 +00:00
Author: https://github.com/stasoid
Commit: 3468a83e45
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2377
Reviewed-by: https://github.com/ADKaster ✅
3 changed files with 200 additions and 18 deletions
|
@ -61,6 +61,24 @@ struct ArgvList {
|
|||
}
|
||||
};
|
||||
|
||||
Process::Process(Process&& other)
|
||||
: m_pid(exchange(other.m_pid, 0))
|
||||
, m_should_disown(exchange(other.m_should_disown, false))
|
||||
{
|
||||
}
|
||||
|
||||
Process& Process::operator=(Process&& other)
|
||||
{
|
||||
m_pid = exchange(other.m_pid, 0);
|
||||
m_should_disown = exchange(other.m_should_disown, false);
|
||||
return *this;
|
||||
}
|
||||
|
||||
Process::~Process()
|
||||
{
|
||||
(void)disown();
|
||||
}
|
||||
|
||||
Process Process::current()
|
||||
{
|
||||
auto p = Process { getpid() };
|
||||
|
@ -297,6 +315,11 @@ void Process::wait_for_debugger_and_break()
|
|||
}
|
||||
}
|
||||
|
||||
pid_t Process::pid() const
|
||||
{
|
||||
return m_pid;
|
||||
}
|
||||
|
||||
ErrorOr<void> Process::disown()
|
||||
{
|
||||
if (m_pid != 0 && m_should_disown) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue