Skip to content

Commit

Permalink
server: Also set process name in /proc/*/stat
Browse files Browse the repository at this point in the history
  • Loading branch information
matteodelabre committed Jun 4, 2021
1 parent e594fc4 commit 0791503
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/server/main.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@

#include <fcntl.h>
#include <fcntl.h>

#include "../shared/ipc.cpp"
#include "../shared/swtfb.cpp"

#include <linux/input.h>
#include <sys/poll.h>
#include <sys/prctl.h>
#include <unistd.h>

#ifndef _GNU_SOURCE
Expand Down Expand Up @@ -173,9 +173,13 @@ int __libc_start_main(int (*_main)(int, char **, char **), int argc,
swtfb::SDK_BIN = argv[0];
fprintf(stderr, "BIN FILE: %s\n", argv[0]);

// Since we preload the library in the Xochitl binary, the process will
// be called 'xochitl' by default. Change this to avoid confusing launchers
const char* proc_name = "rm2fb-server";
size_t argv0_len = strlen(argv[0]);
strncpy(argv[0], "rm2fb-server", argv0_len);
strncpy(argv[0], proc_name, argv0_len);
argv[0][argv0_len] = 0;
prctl(PR_SET_NAME, proc_name);

return func_main(server_main, argc, argv, init, fini, rtld_fini, stack_end);
};
Expand Down

0 comments on commit 0791503

Please sign in to comment.