Use realpath() rather than readlink()
This commit is contained in:
parent
82bc8cc89c
commit
285c53cc67
@ -6,8 +6,9 @@
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <linux/limits.h>
|
||||
#include <stdio.h>
|
||||
#include <limits.h>
|
||||
#include <stdlib.h>
|
||||
#include <libgen.h>
|
||||
|
||||
#define MIN(x, y) ((x) < (y)) ? (x) : (y)
|
||||
@ -17,7 +18,7 @@ int main(int argc, char *argv[]) {
|
||||
char exe[PATH_MAX+1] = {0};
|
||||
char lib[PATH_MAX+1] = {0};
|
||||
char *final_argv[MAX_ARGC + 1] = {0};
|
||||
if (readlink("/proc/self/exe", exe, PATH_MAX) == -1) { fprintf(stderr, "Failed to read /proc/self/exe"); return 1; }
|
||||
if (realpath("/proc/self/exe", exe) == NULL) { fprintf(stderr, "Failed to read /proc/self/exe"); return 1; }
|
||||
char *exe_dir = dirname(exe);
|
||||
int num = snprintf(lib, PATH_MAX, "%s%s", exe_dir, "/../lib/kitty");
|
||||
if (num < 0 || num >= PATH_MAX) { fprintf(stderr, "Failed to create path to /../lib/kitty"); return 1; }
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user