diff terminal.c @ 2425:794ba17f0716

Make termhelper work when current working directory is not the one that contains blastem
author Michael Pavone <pavone@retrodev.com>
date Wed, 24 Jan 2024 20:18:17 -0800
parents 0433fdd9ba66
children
line wrap: on
line diff
--- a/terminal.c	Wed Jan 24 18:51:44 2024 -0800
+++ b/terminal.c	Wed Jan 24 20:18:17 2024 -0800
@@ -26,6 +26,7 @@
 
 void init_terminal()
 {
+#ifndef IS_LIB
 	if (!init_done) {
 		if (!(isatty(STDIN_FILENO) && isatty(STDOUT_FILENO))) {
 #ifndef __APPLE__
@@ -50,11 +51,13 @@
 				warning("Failed to fork for terminal spawn");
 			} else if (!child) {
 				//child process, exec our terminal emulator
+				char *termhelper = bundled_file_path("termhelper");
 #ifdef __APPLE__
-				execlp("open", "open", "./termhelper", NULL);
+				execlp("open", "open", termhelper, NULL);
 #else
-				execlp(term, term, "-title", "BlastEm Debugger", "-e", "./termhelper", NULL);
+				execlp(term, term, "-title", "BlastEm Debugger", "-e", termhelper, NULL);
 #endif
+				free(termhelper);
 			} else {
 				//connect to the FIFOs, these will block so order is important
 				open(INPUT_PATH, O_RDONLY);
@@ -68,4 +71,5 @@
 
 		init_done = 1;
 	}
+#endif
 }