Subprocess
- launch and manage subprocesses
package require Subprocess
set p [Subprocess::Popen #auto cmd]
set rval [$p wait]
::itcl::delete object $p
The 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.
constructor
?-stdout
chan? ?-stderr
chan? ?-stdin
chan? ?-timeout
ms?Raises a Subprocess::Error
if invocation fails for some reason.
method kill
method pid
method process_exists
method timeout_occurred
method terminate
method wait
Deleting a 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.
error
(3caius), signal
(7)