Subprocess - launch and manage subprocesses
package require Subprocess set p [Subprocess::Popen #auto cmd] set rval [$p wait] ::itcl::delete object $p
Popen class takes the pain out of executing subprocesses with Tcl's
open command. You can launch a process, monitor its status and redirect its
standard input and output streams to alternative Tcl channels. By using pipes,
you may even communicate with the process directly, even though you might
prefer to use the
CliDriver(3caius) module in that case.
Launch a subprocess and optionally redirect its standard input and output streams to alternative Tcl channels. If a timeout is specified, the process will be forcefully terminated when it exceeds the timeout.
Subprocess::Error if invocation fails for some reason.
Kill the subprocess. On Unix this is equivalent to sending a SIGKILL.
Return the process ID of the subprocess.
Check if the process is still alive.
Check if a timeout occurred.
Terminate the subprocess. On Unix this is equivalent to sending a SIGTERM.
Wait on the subprocess to end and return its exit code.
Popen object that is associated with an active process, using
itcl::delete object, will implicitely terminate the process. If the process
was terminated pre-maturely, wait will return -1.
Channel descriptors passed as parameters to the
Popen command are
effectively moved to another thread and are hence-forth not accessible anymore
in the calling thread. This does not apply to the standard channels stdout,
stderr and stdin. They keep functioning as expected.