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