ProcessTools Some things to help interact with *n*x processes
Quick intro to the main functions (run each line, watch the post window, wait for a bit):
"sleep 3".unixCmd
"sleep 3".unixCmdInferPID({|pid| ("The PID is" + pid).postln})
"sleep 3".unixCmdThen({|pid| ("The PID was" + pid ++ "; the program has completed").postln})
thor:
"python pyprog.py".unixCmdInferPID({|pid| p = pid; ("The PID is" + pid).postln})
("kill "++p.asString).unixCmd
This toolbox contains the following:
String:unixCmdInferPID(action)
This is like unixCmd except that it also infers the PID that the launched process takes on. This is useful for monitoring long-running processes. The "action" argument is launched once the PID is known.
String:unixCmdThen(action, checkevery)
Runs unixCmd then monitors the process, waiting until it completes.
String:unixCmdGetStdOut
Uses a Pipe to run a command and grab all of the standard output into a string, which is returned.
Integer:isPIDRunning
Checks to see if a UNIX process with PID matching the integer is running.
Score:recordNRTThen
Just like Score's recordNRT methods except wrapped up in the unixCmdThen method described above. This is particularly helpful for running [Non-Realtime-Synthesis] processes and then automatically doing something else once the rendering is complete.