From f29c61baccfe280630825c01f49eb8d8eea6f7ed Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 5 Feb 2016 19:16:35 +0100 Subject: [PATCH] (Linux) Restarting of core in non-HAVE_DYNAMIC mode now properly implemented --- file_path_special.c | 20 ++++++++++---------- frontend/drivers/platform_linux.c | 13 +++++++++++-- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/file_path_special.c b/file_path_special.c index 223f8e69d8..450b71d4cc 100644 --- a/file_path_special.c +++ b/file_path_special.c @@ -138,7 +138,7 @@ void fill_pathname_abbreviate_special(char *out_path, } #if !defined(RARCH_CONSOLE) -void fill_pathname_application_path(char *buf, size_t size) +void fill_pathname_application_path(char *s, size_t len) { #ifdef __APPLE__ CFBundleRef bundle = CFBundleGetMainBundle(); @@ -146,22 +146,22 @@ void fill_pathname_application_path(char *buf, size_t size) size_t i; (void)i; - if (!size) + if (!len) return; #ifdef _WIN32 - DWORD ret = GetModuleFileName(GetModuleHandle(NULL), buf, size - 1); - buf[ret] = '\0'; + DWORD ret = GetModuleFileName(GetModuleHandle(NULL), s, len - 1); + s[ret] = '\0'; #elif defined(__APPLE__) if (bundle) { CFURLRef bundle_url = CFBundleCopyBundleURL(bundle); CFStringRef bundle_path = CFURLCopyPath(bundle_url); - CFStringGetCString(bundle_path, buf, size, kCFStringEncodingUTF8); + CFStringGetCString(bundle_path, s, len, kCFStringEncodingUTF8); CFRelease(bundle_path); CFRelease(bundle_url); - retro_assert(strlcat(buf, "nobin", size) < size); + retro_assert(strlcat(s, "nobin", len) < len); return; } #elif defined(__HAIKU__) @@ -172,7 +172,7 @@ void fill_pathname_application_path(char *buf, size_t size) { if (info.type == B_APP_IMAGE) { - strlcpy(buf, info.name, size); + strlcpy(s, info.name, len); return; } } @@ -182,7 +182,7 @@ void fill_pathname_application_path(char *buf, size_t size) static const char *exts[] = { "exe", "file", "path/a.out" }; char link_path[PATH_MAX_LENGTH] = {0}; - *buf = '\0'; + *s = '\0'; pid = getpid(); /* Linux, BSD and Solaris paths. Not standardized. */ @@ -192,11 +192,11 @@ void fill_pathname_application_path(char *buf, size_t size) snprintf(link_path, sizeof(link_path), "/proc/%u/%s", (unsigned)pid, exts[i]); - ret = readlink(link_path, buf, size - 1); + ret = readlink(link_path, s, len - 1); if (ret >= 0) { - buf[ret] = '\0'; + s[ret] = '\0'; return; } } diff --git a/frontend/drivers/platform_linux.c b/frontend/drivers/platform_linux.c index 98a677dbea..0e95521412 100644 --- a/frontend/drivers/platform_linux.c +++ b/frontend/drivers/platform_linux.c @@ -2145,6 +2145,8 @@ static int frontend_android_parse_drive_list(void *data) #endif #ifndef HAVE_DYNAMIC +#include "../../retroarch.h" + static bool frontend_linux_set_fork(enum frontend_fork fork_mode) { switch (fork_mode) @@ -2159,9 +2161,16 @@ static bool frontend_linux_set_fork(enum frontend_fork fork_mode) break; case FRONTEND_FORK_RESTART: RARCH_LOG("FRONTEND_FORK_RESTART\n"); - /* NOTE: We don't implement Salamander, so just turn - * this into FRONTEND_FORK_CORE. */ linux_fork_mode = FRONTEND_FORK_CORE; + + { + char executable_path[PATH_MAX_LENGTH]; + settings_t *settings = config_get_ptr(); + + fill_pathname_application_path(executable_path, sizeof(executable_path)); + strlcpy(settings->libretro, executable_path, sizeof(settings->libretro)); + } + rarch_ctl(RARCH_CTL_FORCE_QUIT, NULL); break; case FRONTEND_FORK_NONE: default: