Use argv[0] if we can't get_executable_path()
This commit is contained in:
parent
9f652d4729
commit
f0de01379f
@ -36,7 +36,7 @@
|
|||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
task_entry_t *task;
|
task_entry_t *task;
|
||||||
|
|
||||||
platform_init();
|
platform_init(argc, argv);
|
||||||
|
|
||||||
if (argc > 1) {
|
if (argc > 1) {
|
||||||
/* A specific process was requested. */
|
/* A specific process was requested. */
|
||||||
|
|||||||
@ -43,7 +43,7 @@ int main(int argc, char **argv) {
|
|||||||
int total, passed, failed;
|
int total, passed, failed;
|
||||||
task_entry_t* task;
|
task_entry_t* task;
|
||||||
|
|
||||||
platform_init();
|
platform_init(argc, argv);
|
||||||
|
|
||||||
if (argc > 1) {
|
if (argc > 1) {
|
||||||
/* A specific process was requested. */
|
/* A specific process was requested. */
|
||||||
|
|||||||
@ -48,8 +48,9 @@ static void get_executable_path() {
|
|||||||
uint32_t bufsize = sizeof(executable_path);
|
uint32_t bufsize = sizeof(executable_path);
|
||||||
_NSGetExecutablePath(executable_path, &bufsize);
|
_NSGetExecutablePath(executable_path, &bufsize);
|
||||||
}
|
}
|
||||||
#else
|
#endif
|
||||||
/* Linux-only */
|
|
||||||
|
#ifdef __linux__
|
||||||
static void get_executable_path() {
|
static void get_executable_path() {
|
||||||
if (!executable_path[0]) {
|
if (!executable_path[0]) {
|
||||||
readlink("/proc/self/exe", executable_path, PATHMAX - 1);
|
readlink("/proc/self/exe", executable_path, PATHMAX - 1);
|
||||||
@ -59,10 +60,15 @@ static void get_executable_path() {
|
|||||||
|
|
||||||
|
|
||||||
/* Do platform-specific initialization. */
|
/* Do platform-specific initialization. */
|
||||||
void platform_init() {
|
void platform_init(int argc, char **argv) {
|
||||||
/* Disable stdio output buffering. */
|
/* Disable stdio output buffering. */
|
||||||
setvbuf(stdout, NULL, _IONBF, 0);
|
setvbuf(stdout, NULL, _IONBF, 0);
|
||||||
setvbuf(stderr, NULL, _IONBF, 0);
|
setvbuf(stderr, NULL, _IONBF, 0);
|
||||||
|
#ifdef get_executable_path
|
||||||
|
get_executable_path();
|
||||||
|
#else
|
||||||
|
strcpy(executable_path, argv[0]);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -78,8 +84,6 @@ int process_start(char* name, process_info_t* p) {
|
|||||||
p->terminated = 0;
|
p->terminated = 0;
|
||||||
p->status = 0;
|
p->status = 0;
|
||||||
|
|
||||||
get_executable_path();
|
|
||||||
|
|
||||||
pid_t pid = vfork();
|
pid_t pid = vfork();
|
||||||
|
|
||||||
if (pid < 0) {
|
if (pid < 0) {
|
||||||
|
|||||||
@ -39,7 +39,7 @@
|
|||||||
|
|
||||||
|
|
||||||
/* Do platform-specific initialization. */
|
/* Do platform-specific initialization. */
|
||||||
void platform_init() {
|
void platform_init(int argc, char **argv) {
|
||||||
/* Disable the "application crashed" popup. */
|
/* Disable the "application crashed" popup. */
|
||||||
SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX |
|
SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX |
|
||||||
SEM_NOOPENFILEERRORBOX);
|
SEM_NOOPENFILEERRORBOX);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user