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
|
|
|
|
|
2021-06-03 10:21:04 +00:00
|
|
|
#include <AK/IntrusiveList.h>
|
2020-08-15 19:13:19 +00:00
|
|
|
#include <AK/RefCounted.h>
|
|
|
|
#include <AK/Weakable.h>
|
2021-08-07 11:12:35 +00:00
|
|
|
#include <Kernel/Locking/SpinLockProtectedValue.h>
|
2020-08-15 19:13:19 +00:00
|
|
|
#include <Kernel/UnixTypes.h>
|
|
|
|
|
|
|
|
namespace Kernel {
|
|
|
|
|
|
|
|
class ProcessGroup
|
|
|
|
: public RefCounted<ProcessGroup>
|
2021-06-03 10:21:04 +00:00
|
|
|
, public Weakable<ProcessGroup> {
|
2020-08-15 19:13:19 +00:00
|
|
|
|
|
|
|
AK_MAKE_NONMOVABLE(ProcessGroup);
|
|
|
|
AK_MAKE_NONCOPYABLE(ProcessGroup);
|
|
|
|
|
|
|
|
public:
|
|
|
|
~ProcessGroup();
|
|
|
|
|
2021-05-18 09:07:25 +00:00
|
|
|
static RefPtr<ProcessGroup> create(ProcessGroupID);
|
|
|
|
static RefPtr<ProcessGroup> find_or_create(ProcessGroupID);
|
2020-11-29 23:05:27 +00:00
|
|
|
static RefPtr<ProcessGroup> from_pgid(ProcessGroupID);
|
2020-08-15 19:13:19 +00:00
|
|
|
|
|
|
|
const ProcessGroupID& pgid() const { return m_pgid; }
|
|
|
|
|
|
|
|
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:
|
|
|
|
using List = IntrusiveList<ProcessGroup, RawPtr<ProcessGroup>, &ProcessGroup::m_list_node>;
|
2020-08-15 19:13:19 +00:00
|
|
|
};
|
|
|
|
|
2021-08-07 11:12:35 +00:00
|
|
|
SpinLockProtectedValue<ProcessGroup::List>& process_groups();
|
2020-08-15 19:13:19 +00:00
|
|
|
|
|
|
|
}
|