Serenity Operating System
at master 26 lines 625 B view raw
1/* 2 * Copyright (c) 2020, Andreas Kling <kling@serenityos.org> 3 * 4 * SPDX-License-Identifier: BSD-2-Clause 5 */ 6 7#include <Kernel/Process.h> 8 9namespace Kernel { 10 11ErrorOr<FlatPtr> Process::sys$disown(ProcessID pid) 12{ 13 VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this); 14 TRY(require_promise(Pledge::proc)); 15 auto process = Process::from_pid_in_same_jail(pid); 16 if (!process) 17 return ESRCH; 18 if (process->ppid() != this->pid()) 19 return ECHILD; 20 process->with_mutable_protected_data([](auto& protected_data) { 21 protected_data.ppid = 0; 22 }); 23 process->disowned_by_waiter(*this); 24 return 0; 25} 26}