LibCore: Implement Process::get_name for linux and macos

This commit is contained in:
Sebastian Zaha 2023-08-02 10:18:16 +02:00 committed by Andrew Kaster
parent 1b5b1e4153
commit 002e206af0
Notes: sideshowbarker 2024-07-16 21:51:02 +09:00

View File

@ -114,6 +114,11 @@ ErrorOr<String> Process::get_name()
if (rc != 0)
return Error::from_syscall("get_process_name"sv, -rc);
return String::from_utf8(StringView { buffer, strlen(buffer) });
#elif defined(AK_OS_LINUX)
return String::from_utf8(StringView { program_invocation_name, strlen(program_invocation_name) });
#elif defined(AK_OS_BSD_GENERIC)
auto const* progname = getprogname();
return String::from_utf8(StringView { progname, strlen(progname) });
#else
// FIXME: Implement Process::get_name() for other platforms.
return "???"_short_string;