Fix up binpath discovery which was totally broken

This commit is contained in:
K. Lange 2021-02-10 14:44:59 +09:00
parent dce6c4b79e
commit f9cfa4e622
2 changed files with 3 additions and 2 deletions

View File

@ -287,7 +287,7 @@ static void findInterpreter(char * argv[]) {
#else
/* Try asking /proc */
char * binpath = realpath("/proc/self/exe", NULL);
if (!binpath) {
if (!binpath || (access(binpath, X_OK) != 0)) {
if (strchr(argv[0], '/')) {
binpath = realpath(argv[0], NULL);
} else {
@ -300,7 +300,7 @@ static void findInterpreter(char * argv[]) {
char tmp[4096];
sprintf(tmp, "%s/%s", path, argv[0]);
if (access(tmp, X_OK)) {
if (access(tmp, X_OK) == 0) {
binpath = strdup(tmp);
break;
}

View File

@ -1,6 +1,7 @@
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include "kuroko.h"
#include "scanner.h"