ztcl::pty pid
Gives the process id of the program.
ztcl::pty pid CHANNEL
Description
Gives the process id of the program of spawn, as the system of the interpreter numbers it. In a thread of the level process on Linux, the thread has a PID namespace of its own, so the id is the id in that namespace, as the program sees it. The id stays after the end of the program, until close.
Arguments
| Argument | Type | Default | Description |
|---|---|---|---|
| CHANNEL | channel | required | A channel of spawn. |
Returns
An integer above 0.
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 p [ztcl::pty pid $t]
> close $t
> expr {$p > 0}
1
Errors
% ztcl::pty pid stdout
channel "stdout" is not a pty
-errorcode NONE
% ztcl::pty pid
wrong # args: should be "ztcl::pty pid 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.4