2020-08-04 11:51:11 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
*
|
2021-04-22 08:24:48 +00:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-08-04 11:51:11 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <Kernel/Process.h>
|
|
|
|
|
|
|
|
namespace Kernel {
|
|
|
|
|
2021-06-28 18:59:35 +00:00
|
|
|
KResultOr<FlatPtr> Process::sys$disown(ProcessID pid)
|
2020-08-04 11:51:11 +00:00
|
|
|
{
|
2021-07-18 18:20:12 +00:00
|
|
|
VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this);
|
2020-08-04 11:51:11 +00:00
|
|
|
REQUIRE_PROMISE(proc);
|
|
|
|
auto process = Process::from_pid(pid);
|
|
|
|
if (!process)
|
2021-03-01 12:49:16 +00:00
|
|
|
return ESRCH;
|
2020-08-04 11:51:11 +00:00
|
|
|
if (process->ppid() != this->pid())
|
2021-03-01 12:49:16 +00:00
|
|
|
return ECHILD;
|
2021-03-11 12:13:05 +00:00
|
|
|
ProtectedDataMutationScope scope(*process);
|
2021-08-07 19:30:06 +00:00
|
|
|
process->m_protected_values.ppid = 0;
|
2020-12-09 02:04:05 +00:00
|
|
|
process->disowned_by_waiter(*this);
|
2020-08-04 11:51:11 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|