!7 cmodule RunCheetah > DynPrintLogAndEnabled { transient Process process; start-thread { dm_registerAs_direct runCheetah(); dm_reloadOnFieldChange enabled(); _startIt(); } void _startIt q { cleanMeUp_process(); if (!enabled) ret; File script = userDir("dev/cheetah/speech-loop"); assertFileExists(script); print("Calling " + script); process = Runtime.getRuntime().exec(platformQuoteOpt(bashExecutable()) + " " + platformQuoteOpt(script)); print("Cheetah process started"); print("PID: " + getOpt(process, "pid")); drainErrorStreamToConsole(process, line -> enabled, lambda0 enter); //out = new PrintStream(process.getOutputStream()); dm_startThread("Cheetah Recognition", r { drainStreamToPrint_charByChar_onChar_onLine(process.getInputStream(), () -> enabled, c -> vmBus_send cheetahCharRecognized(module(), c), line -> { if (!contains(line, "[WARN]")) vmBus_send cheetahLineRecognized(module(), line); }); }); } void cleanMeUp_process { if (process != null) { print("Stopping Cheetah process"); process.destroy/*Forcibly*/(); process = null; print("Stopped Cheetah process, hopefully"); } } }