mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-23 08:00:20 +00:00
1682f0b760
SPDX License Identifiers are a more compact / standardized way of representing file license information. See: https://spdx.dev/resources/use/#identifiers This was done with the `ambr` search and replace tool. ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
49 lines
1.3 KiB
C++
49 lines
1.3 KiB
C++
/*
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <Kernel/Debug.h>
|
|
#include <Kernel/Process.h>
|
|
|
|
namespace Kernel {
|
|
|
|
KResultOr<siginfo_t> Process::do_waitid(idtype_t idtype, int id, int options)
|
|
{
|
|
KResultOr<siginfo_t> result = KResult(KSuccess);
|
|
if (Thread::current()->block<Thread::WaitBlocker>({}, options, idtype, id, result).was_interrupted())
|
|
return EINTR;
|
|
VERIFY(!result.is_error() || (options & WNOHANG) || result.error() != KSuccess);
|
|
return result;
|
|
}
|
|
|
|
KResultOr<pid_t> Process::sys$waitid(Userspace<const Syscall::SC_waitid_params*> user_params)
|
|
{
|
|
REQUIRE_PROMISE(proc);
|
|
|
|
Syscall::SC_waitid_params params;
|
|
if (!copy_from_user(¶ms, user_params))
|
|
return EFAULT;
|
|
|
|
switch (params.idtype) {
|
|
case P_ALL:
|
|
case P_PID:
|
|
case P_PGID:
|
|
break;
|
|
default:
|
|
return EINVAL;
|
|
}
|
|
|
|
dbgln_if(PROCESS_DEBUG, "sys$waitid({}, {}, {}, {})", params.idtype, params.id, params.infop, params.options);
|
|
|
|
auto siginfo_or_error = do_waitid(static_cast<idtype_t>(params.idtype), params.id, params.options);
|
|
if (siginfo_or_error.is_error())
|
|
return siginfo_or_error.error();
|
|
|
|
if (!copy_to_user(params.infop, &siginfo_or_error.value()))
|
|
return EFAULT;
|
|
return 0;
|
|
}
|
|
|
|
}
|