mirror of
https://github.com/clearlinux/linux-steam-integration.git
synced 2026-09-07 06:11:41 +00:00
redirect: Add the usual get_process_name dance
Signed-off-by: Ikey Doherty <ikey@solus-project.com>
This commit is contained in:
+28
-1
@@ -11,12 +11,39 @@
|
||||
|
||||
#define _GNU_SOURCE
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "nica/util.h"
|
||||
|
||||
/**
|
||||
* Determine the basename'd process
|
||||
*/
|
||||
static inline char *get_process_name(void)
|
||||
{
|
||||
autofree(char) *realp = NULL;
|
||||
char *basep = NULL;
|
||||
|
||||
realp = realpath("/proc/self/exe", NULL);
|
||||
if (!realp) {
|
||||
return false;
|
||||
}
|
||||
|
||||
basep = basename(realp);
|
||||
return strdup(basep);
|
||||
}
|
||||
|
||||
__attribute__((constructor)) static void lsi_redirect_init(void)
|
||||
{
|
||||
fprintf(stderr, "Loading lsi_redirect\n");
|
||||
autofree(char) *process_name = get_process_name();
|
||||
if (!process_name) {
|
||||
fprintf(stderr, "Failure to allocate memory! %s\n", strerror(errno));
|
||||
return;
|
||||
}
|
||||
fprintf(stderr, "Loading lsi_redirect for: %s\n", process_name);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -10,6 +10,7 @@ if with_libredirect == true
|
||||
'lsi-redirect',
|
||||
sources: redirect_sources,
|
||||
c_args: ['-fvisibility=hidden'],
|
||||
include_directories: nica_includes,
|
||||
install: true,
|
||||
)
|
||||
endif
|
||||
|
||||
Reference in New Issue
Block a user