| process(3tcl) | Tcl Built-In Commands | process(3tcl) |
tcl::process - Subprocess management
::tcl::process option ?arg arg ...?
This command provides a way to manage subprocesses created by the open and exec commands, as identified by the process identifiers (PIDs) of those subprocesses. The legal options (which may be abbreviated) are:
Note that msg and errorCode are only present for abnormally terminated processes (i.e. those where the code is nonzero). Under the hood this command calls Tcl_WaitPid with the WNOHANG flag set for non-blocking behavior, unless the -wait switch is set (see below).
Additionally, ::tcl::process status accepts the following switches:
These show the use of ::tcl::process. Some of the results from ::tcl::process status are split over multiple lines for readability.
::tcl::process autopurge
→ true ::tcl::process autopurge false
→ false set pid1 [exec command1 a b c | command2 d e f &]
→ 123 456 set chan [open "|command1 a b c | command2 d e f"]
→ file123 set pid2 [pid $chan]
→ 789 1011 ::tcl::process list
→ 123 456 789 1011 ::tcl::process status
→ 123 0
456 {1 "child killed: write on pipe with no readers" {
CHILDKILLED 456 SIGPIPE "write on pipe with no readers"}}
789 {1 "child suspended: background tty read" {
CHILDSUSP 789 SIGTTIN "background tty read"}}
1011 {} ::tcl::process status 123
→ 123 0 ::tcl::process status 1011
→ 1011 {} ::tcl::process status -wait
→ 123 0
456 {1 "child killed: write on pipe with no readers" {
CHILDKILLED 456 SIGPIPE "write on pipe with no readers"}}
789 {1 "child suspended: background tty read" {
CHILDSUSP 789 SIGTTIN "background tty read"}}
1011 {1 "child process exited abnormally" {
CHILDSTATUS 1011 -1}} ::tcl::process status 1011
→ 1011 {1 "child process exited abnormally" {
CHILDSTATUS 1011 -1}} ::tcl::process purge exec command1 1 2 3 &
→ 1213 ::tcl::process list
→ 1213
exec(3tcl), open(3tcl), pid(3tcl), Tcl_DetachPids(3tcl), Tcl_WaitPid(3tcl), Tcl_ReapDetachedProcs(3tcl)
background, child, detach, process, wait
| 9.0 | Tcl |