2020-08-04 13:51:11 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-08-04 13:51:11 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <Kernel/Process.h>
|
|
|
|
|
|
|
|
namespace Kernel {
|
|
|
|
|
2021-11-08 00:51:39 +01:00
|
|
|
ErrorOr<FlatPtr> Process::sys$disown(ProcessID pid)
|
2020-08-04 13:51:11 +02:00
|
|
|
{
|
2021-07-18 11:20:12 -07:00
|
|
|
VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this);
|
2021-12-29 01:11:45 -08:00
|
|
|
TRY(require_promise(Pledge::proc));
|
2022-11-02 22:26:02 +02:00
|
|
|
auto process = Process::from_pid_in_same_jail(pid);
|
2020-08-04 13:51:11 +02:00
|
|
|
if (!process)
|
2021-03-01 13:49:16 +01:00
|
|
|
return ESRCH;
|
2020-08-04 13:51:11 +02:00
|
|
|
if (process->ppid() != this->pid())
|
2021-03-01 13:49:16 +01:00
|
|
|
return ECHILD;
|
2022-08-21 12:18:26 +02:00
|
|
|
process->with_mutable_protected_data([](auto& protected_data) {
|
|
|
|
protected_data.ppid = 0;
|
|
|
|
});
|
2020-12-08 19:04:05 -07:00
|
|
|
process->disowned_by_waiter(*this);
|
2020-08-04 13:51:11 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|