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-11-07 23:51:39 +00:00
|
|
|
ErrorOr<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);
|
2021-12-29 09:11:45 +00:00
|
|
|
TRY(require_promise(Pledge::proc));
|
2020-08-04 11:51:11 +00:00
|
|
|
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;
|
2022-08-21 10:18:26 +00:00
|
|
|
process->with_mutable_protected_data([](auto& protected_data) {
|
|
|
|
protected_data.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;
|
|
|
|
}
|
|
|
|
}
|