LibCore: Remove unused KeepAsChild and disown mechanisms

Those went unused and did nothing on systems other than SerenityOS.
This commit is contained in:
Undefine 2025-08-13 14:02:29 +02:00 committed by Jelle Raaijmakers
parent 7a9dd46a39
commit 769bbe6021
Notes: github-actions[bot] 2025-11-07 10:29:22 +00:00
4 changed files with 7 additions and 44 deletions

View file

@ -63,26 +63,22 @@ struct ArgvList {
Process::Process(Process&& other)
: m_pid(exchange(other.m_pid, 0))
, m_should_disown(exchange(other.m_should_disown, false))
{
}
Process& Process::operator=(Process&& other)
{
m_pid = exchange(other.m_pid, 0);
m_should_disown = exchange(other.m_should_disown, false);
return *this;
}
Process::~Process()
{
(void)disown();
}
Process Process::current()
{
auto p = Process { getpid() };
p.m_should_disown = false;
return p;
}
@ -134,20 +130,17 @@ ErrorOr<Process> Process::spawn(ProcessSpawnOptions const& options)
return Process { pid };
}
ErrorOr<Process> Process::spawn(StringView path, ReadonlySpan<ByteString> arguments, KeepAsChild keep_as_child)
ErrorOr<Process> Process::spawn(StringView path, ReadonlySpan<ByteString> arguments)
{
auto process = TRY(spawn({
.executable = path,
.arguments = Vector<ByteString> { arguments },
}));
if (keep_as_child == KeepAsChild::No)
TRY(process.disown());
return process;
}
ErrorOr<Process> Process::spawn(StringView path, ReadonlySpan<StringView> arguments, KeepAsChild keep_as_child)
ErrorOr<Process> Process::spawn(StringView path, ReadonlySpan<StringView> arguments)
{
Vector<ByteString> backing_strings;
backing_strings.ensure_capacity(arguments.size());
@ -159,9 +152,6 @@ ErrorOr<Process> Process::spawn(StringView path, ReadonlySpan<StringView> argume
.arguments = backing_strings,
}));
if (keep_as_child == KeepAsChild::No)
TRY(process.disown());
return process;
}
@ -293,21 +283,6 @@ pid_t Process::pid() const
return m_pid;
}
ErrorOr<void> Process::disown()
{
if (m_pid != 0 && m_should_disown) {
#ifdef AK_OS_SERENITY
TRY(System::disown(m_pid));
#else
// FIXME: Support disown outside Serenity.
#endif
m_should_disown = false;
return {};
} else {
return Error::from_errno(EINVAL);
}
}
ErrorOr<int> Process::wait_for_termination()
{
VERIFY(m_pid > 0);
@ -328,7 +303,6 @@ ErrorOr<int> Process::wait_for_termination()
VERIFY_NOT_REACHED();
}
m_should_disown = false;
return exit_code;
}

View file

@ -50,11 +50,6 @@ class Process {
AK_MAKE_NONCOPYABLE(Process);
public:
enum class KeepAsChild {
Yes,
No
};
Process(Process&& other);
Process& operator=(Process&& other);
~Process();
@ -62,8 +57,8 @@ public:
static ErrorOr<Process> spawn(ProcessSpawnOptions const& options);
static Process current();
static ErrorOr<Process> spawn(StringView path, ReadonlySpan<ByteString> arguments, KeepAsChild keep_as_child = KeepAsChild::No);
static ErrorOr<Process> spawn(StringView path, ReadonlySpan<StringView> arguments, KeepAsChild keep_as_child = KeepAsChild::No);
static ErrorOr<Process> spawn(StringView path, ReadonlySpan<ByteString> arguments);
static ErrorOr<Process> spawn(StringView path, ReadonlySpan<StringView> arguments);
static ErrorOr<String> get_name();
@ -72,22 +67,16 @@ public:
pid_t pid() const;
#ifndef AK_OS_WINDOWS
ErrorOr<void> disown();
#endif
ErrorOr<int> wait_for_termination();
private:
#ifndef AK_OS_WINDOWS
Process(pid_t pid = -1)
: m_pid(pid)
, m_should_disown(true)
{
}
pid_t m_pid;
bool m_should_disown;
#else
Process(void* handle = 0)
: m_handle(handle)

View file

@ -77,7 +77,7 @@ ErrorOr<Process> Process::spawn(ProcessSpawnOptions const& options)
return Process(process_info.hProcess);
}
ErrorOr<Process> Process::spawn(StringView path, ReadonlySpan<ByteString> arguments, KeepAsChild)
ErrorOr<Process> Process::spawn(StringView path, ReadonlySpan<ByteString> arguments)
{
return spawn({
.executable = path,
@ -85,7 +85,7 @@ ErrorOr<Process> Process::spawn(StringView path, ReadonlySpan<ByteString> argume
});
}
ErrorOr<Process> Process::spawn(StringView path, ReadonlySpan<StringView> arguments, KeepAsChild)
ErrorOr<Process> Process::spawn(StringView path, ReadonlySpan<StringView> arguments)
{
Vector<ByteString> backing_strings;
backing_strings.ensure_capacity(arguments.size());

View file

@ -26,7 +26,7 @@ static ErrorOr<Core::Process> launch_process(StringView application, ReadonlySpa
ErrorOr<Core::Process> result = Error::from_string_literal("All paths failed to launch");
for (auto const& path : paths) {
auto path_view = path.view();
result = Core::Process::spawn(path_view, arguments, Core::Process::KeepAsChild::Yes);
result = Core::Process::spawn(path_view, arguments);
if (!result.is_error())
break;
}