mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
UserspaceEmulator: Set the process and thread name to "(UE) Executable"
This makes it much easier to see who's who when running multiple emulators at the same time. :^)
This commit is contained in:
parent
e26c6805dd
commit
db1b67e88a
Notes:
sideshowbarker
2024-07-19 04:33:30 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/db1b67e88a1
2 changed files with 17 additions and 1 deletions
|
@ -10,4 +10,4 @@ set(SOURCES
|
|||
)
|
||||
|
||||
serenity_bin(UserspaceEmulator)
|
||||
target_link_libraries(UserspaceEmulator LibX86 LibDebug LibCore)
|
||||
target_link_libraries(UserspaceEmulator LibX86 LibDebug LibCore LibPthread)
|
||||
|
|
|
@ -26,11 +26,15 @@
|
|||
|
||||
#include "Emulator.h"
|
||||
#include "SoftCPU.h"
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <AK/LogStream.h>
|
||||
#include <AK/MappedFile.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibELF/Loader.h>
|
||||
#include <getopt.h>
|
||||
#include <pthread.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(int argc, char** argv, char** env)
|
||||
{
|
||||
|
@ -64,5 +68,17 @@ int main(int argc, char** argv, char** env)
|
|||
if (!emulator.load_elf())
|
||||
return 1;
|
||||
|
||||
StringBuilder builder;
|
||||
builder.append("(UE) ");
|
||||
builder.append(LexicalPath(arguments[0]).basename());
|
||||
if (set_process_name(builder.string_view().characters_without_null_termination(), builder.string_view().length()) < 0) {
|
||||
perror("set_process_name");
|
||||
return 1;
|
||||
}
|
||||
int rc = pthread_setname_np(pthread_self(), builder.to_string().characters());
|
||||
if (rc != 0) {
|
||||
fprintf(stderr, "pthread_setname_np: %s\n", strerror(rc));
|
||||
return 1;
|
||||
}
|
||||
return emulator.exec();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue