beetlebug▾
/

ztcl::pty status

Gives whether the program runs, or how it ended.

ztcl::pty status CHANNEL

Description

Gives running, {exit CODE}, or {signal NAME}, such as {signal KILL}, with no wait. The status stays until close, and close ends the program and does not report its exit code as an error, since a terminal program often ends with a code other than 0.

Arguments

ArgumentTypeDefaultDescription
CHANNELchannelrequiredA channel of spawn.

Returns

running, a list of exit and a code, or a list of signal and a name.

Examples

Each example of this page runs after # The shell of the platform: in host mode the separator of Windows is a backslash. set sh [expr {[file separator] eq "/" ? "/bin/sh" : "cmd.exe"}] # Reads the output with no block until the program ends, and gives its status. proc finish {t} { fconfigure $t -blocking 0 for {set n 0} {[ztcl::pty status $t] eq "running" && $n < 1000} {incr n} { read $t; after 10 } ztcl::pty status $t } .

% set t [ztcl::pty spawn $sh]
> set a [ztcl::pty status $t]
> puts -nonewline $t "exit 3\r"
> set b [finish $t]
> close $t
> list $a $b
running {exit 3}

Errors

% ztcl::pty status stdout
channel "stdout" is not a pty
-errorcode NONE

% ztcl::pty status
wrong # args: should be "ztcl::pty status channel"
-errorcode TCL WRONGARGS

Facts

Capability
exec. A new interpreter does not have it until the host turns it on.
Tcl release
Tcl 9.1 and 8.6.
Since
ztcl 1.0.0-beta.1

See also