From 6c8bab90c649767e7e5ebda979f648e04af376a1 Mon Sep 17 00:00:00 2001 From: Jesper Gravgaard Date: Sun, 27 Aug 2023 19:33:52 +0200 Subject: [PATCH] Fixed #827 problem with starting Vice64 on Windows by using ProcessBuilder. --- src/main/java/dk/camelot64/kickc/KickC.java | 23 ++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/main/java/dk/camelot64/kickc/KickC.java b/src/main/java/dk/camelot64/kickc/KickC.java index 53528d19e..deac23b15 100644 --- a/src/main/java/dk/camelot64/kickc/KickC.java +++ b/src/main/java/dk/camelot64/kickc/KickC.java @@ -499,25 +499,34 @@ public class KickC implements Callable { // Execute the binary file if instructed if(emulator != null) { + List emulatorCommand = new ArrayList<>(); + emulatorCommand.addAll(Arrays.asList(emulator.split(" "))); + // Find commandline options for the emulator - String emuOptions = ""; - if(emulator.equals("C64Debugger")) { + if( emulator.equals("C64Debugger") ) { Path viceSymbolsPath = program.getOutputFileManager().getOutputFile("vs"); - emuOptions = "-symbols " + viceSymbolsPath + " -autojmp -prg "; + emulatorCommand.add("-symbol"); + emulatorCommand.add(viceSymbolsPath.toString()); + emulatorCommand.add("-autojmp"); + emulatorCommand.add("-prg"); } // The program names used by VICE emulators List viceEmus = Arrays.asList("x64", "x64sc", "x128", "x64dtv", "xcbm2", "xcbm5x0", "xpet", "xplus4", "xscpu64", "xvic"); if(viceEmus.contains(emulator)) { Path viceSymbolsPath = program.getOutputFileManager().getOutputFile("vs"); - emuOptions = "-moncommands " + viceSymbolsPath.toAbsolutePath().toString() + " "; + emulatorCommand.add("-moncommands"); + emulatorCommand.add(viceSymbolsPath.toAbsolutePath().toString()); } + emulatorCommand.add(outputBinaryFilePath.toAbsolutePath().toString()); System.out.println("Executing " + outputBinaryFilePath + " using " + emulator); - String executeCommand = emulator + " " + emuOptions + outputBinaryFilePath.toAbsolutePath().toString(); if(verbose) { - System.out.println("Executing command: " + executeCommand); + System.out.println("Executing command: " + String.join(" ", emulatorCommand)); } try { - Process process = Runtime.getRuntime().exec(executeCommand); + ProcessBuilder processBuilder = new ProcessBuilder(); + processBuilder.command(emulatorCommand); + processBuilder.inheritIO(); + Process process = processBuilder.start(); process.waitFor(); } catch(Throwable e) { System.err.println("Executing emulator failed! " + e.getMessage());