beetlebug▾
/

ztcl::pty kill

Sends a signal to the program.

ztcl::pty kill CHANNEL ?SIGNAL?

Description

Sends SIGNAL to the program: HUP by default, INT, QUIT, KILL, TERM, CONT, STOP, WINCH, the same names with SIG in front, or a number from 1 to 64. On Linux and macOS the signal goes to the process group, and a number is the number of the system, so STOP and CONT differ: 19 and 18 on Linux, 17 and 19 on macOS. On Windows INT writes Ctrl-C (byte 3) to the input, CONT, STOP, and WINCH have no effect, each other signal ends the Job Object, and the numbers are 1, 2, 3, 9, and 15.

Arguments

ArgumentTypeDefaultDescription
CHANNELchannelrequiredA channel of spawn.
SIGNALsignal name or numbernoneThe signal to send.

Returns

An empty string.

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]
> ztcl::pty kill $t KILL
> set s [finish $t]
> close $t
> set s
signal KILL

Errors

% set t [ztcl::pty spawn $sh]
> catch {ztcl::pty kill $t BOGUS} m o
> close $t
> return -options $o $m
bad signal "BOGUS": must be HUP, INT, QUIT, KILL, TERM, CONT, STOP, WINCH, or a number
-errorcode NONE

% set t [ztcl::pty spawn $sh]
> catch {ztcl::pty kill $t 99} m o
> close $t
> return -options $o $m
bad signal "99"
-errorcode NONE

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

% ztcl::pty kill
wrong # args: should be "ztcl::pty kill channel ?signal?"
-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