redirect: Add the usual get_process_name dance

Signed-off-by: Ikey Doherty <ikey@solus-project.com>
This commit is contained in:
Ikey Doherty
2017-10-21 17:52:35 +01:00
parent 0eb0d09119
commit bb29a04078
2 changed files with 29 additions and 1 deletions
+28 -1
View File
@@ -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);
}
/*
+1
View File
@@ -10,6 +10,7 @@ if with_libredirect == true
'lsi-redirect',
sources: redirect_sources,
c_args: ['-fvisibility=hidden'],
include_directories: nica_includes,
install: true,
)
endif