2020-08-15 19:13:19 +00:00
|
|
|
/*
|
2023-04-04 14:38:46 +00:00
|
|
|
* Copyright (c) 2020-2023, the SerenityOS developers.
|
2020-08-15 19:13:19 +00:00
|
|
|
*
|
2021-04-22 08:24:48 +00:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-08-15 19:13:19 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2021-06-03 10:21:04 +00:00
|
|
|
#include <AK/IntrusiveList.h>
|
2023-04-02 19:57:12 +00:00
|
|
|
#include <AK/RefPtr.h>
|
2022-10-25 16:53:04 +00:00
|
|
|
#include <Kernel/Forward.h>
|
2023-04-04 14:38:46 +00:00
|
|
|
#include <Kernel/Library/ListedRefCounted.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
|
2023-04-04 14:38:46 +00:00
|
|
|
: public ListedRefCounted<ProcessGroup, LockType::Spinlock>
|
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();
|
|
|
|
|
2023-04-04 14:38:46 +00:00
|
|
|
static ErrorOr<NonnullRefPtr<ProcessGroup>> create_if_unused_pgid(ProcessGroupID);
|
2023-04-02 19:57:12 +00:00
|
|
|
static ErrorOr<NonnullRefPtr<ProcessGroup>> find_or_create(ProcessGroupID);
|
|
|
|
static RefPtr<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)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ProcessGroupID m_pgid;
|
2021-06-03 10:21:04 +00:00
|
|
|
|
2023-04-04 14:38:46 +00:00
|
|
|
mutable IntrusiveListNode<ProcessGroup> m_list_node;
|
|
|
|
|
2021-06-03 10:21:04 +00:00
|
|
|
public:
|
2023-04-04 14:38:46 +00:00
|
|
|
using AllInstancesList = IntrusiveList<&ProcessGroup::m_list_node>;
|
|
|
|
static SpinlockProtected<AllInstancesList, LockRank::None>& all_instances();
|
2020-08-15 19:13:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|