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