2020-08-15 19:13:19 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2020, the SerenityOS developers.
|
|
|
|
*
|
2021-04-22 08:24:48 +00:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-08-15 19:13:19 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2022-08-19 15:26:07 +00:00
|
|
|
#include <AK/AtomicRefCounted.h>
|
2021-06-03 10:21:04 +00:00
|
|
|
#include <AK/IntrusiveList.h>
|
2022-10-25 16:53:04 +00:00
|
|
|
#include <Kernel/Forward.h>
|
2022-08-19 18:53:40 +00:00
|
|
|
#include <Kernel/Library/LockWeakable.h>
|
2021-08-21 23:37:17 +00:00
|
|
|
#include <Kernel/Locking/SpinlockProtected.h>
|
2020-08-15 19:13:19 +00:00
|
|
|
#include <Kernel/UnixTypes.h>
|
|
|
|
|
|
|
|
namespace Kernel {
|
|
|
|
|
|
|
|
class ProcessGroup
|
2022-08-19 15:26:07 +00:00
|
|
|
: public AtomicRefCounted<ProcessGroup>
|
2022-08-19 18:53:40 +00:00
|
|
|
, public LockWeakable<ProcessGroup> {
|
2020-08-15 19:13:19 +00:00
|
|
|
|
|
|
|
AK_MAKE_NONMOVABLE(ProcessGroup);
|
|
|
|
AK_MAKE_NONCOPYABLE(ProcessGroup);
|
|
|
|
|
|
|
|
public:
|
|
|
|
~ProcessGroup();
|
|
|
|
|
2022-08-19 18:53:40 +00:00
|
|
|
static ErrorOr<NonnullLockRefPtr<ProcessGroup>> try_create(ProcessGroupID);
|
|
|
|
static ErrorOr<NonnullLockRefPtr<ProcessGroup>> try_find_or_create(ProcessGroupID);
|
|
|
|
static LockRefPtr<ProcessGroup> from_pgid(ProcessGroupID);
|
2020-08-15 19:13:19 +00:00
|
|
|
|
2022-04-01 17:58:27 +00:00
|
|
|
ProcessGroupID const& pgid() const { return m_pgid; }
|
2020-08-15 19:13:19 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
ProcessGroup(ProcessGroupID pgid)
|
|
|
|
: m_pgid(pgid)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-06-03 10:21:04 +00:00
|
|
|
IntrusiveListNode<ProcessGroup> m_list_node;
|
2020-08-15 19:13:19 +00:00
|
|
|
ProcessGroupID m_pgid;
|
2021-06-03 10:21:04 +00:00
|
|
|
|
|
|
|
public:
|
2021-09-09 12:00:59 +00:00
|
|
|
using List = IntrusiveList<&ProcessGroup::m_list_node>;
|
2020-08-15 19:13:19 +00:00
|
|
|
};
|
|
|
|
|
2021-08-21 23:37:17 +00:00
|
|
|
SpinlockProtected<ProcessGroup::List>& process_groups();
|
2020-08-15 19:13:19 +00:00
|
|
|
|
|
|
|
}
|