Jeff Smith 2026-03-18 : CloudTk was only compatible with Tcl 8.6 and one of the extension it uses is Standalone Bgexec from the wiki. With the release of Tcl 9.0, one of the hurdles to overcome was to build a Tcl 9.0 version of Standalone Bgexec so CloudTk would work with Tcl 9.0. Checking the BLT Sourceforge site, I was surprised to see it had been updated on 20 June 2025. Looking at the bltBgexec.c source code some new options had been added and something I did not know is, it had Windows support has well. I know nothing about C programming but with all the hype about AI, I wondered if AI could make a Tcl 9.0 Critcl wrapper for me. The latest Critcl 3.3.1 can make a wrapper that works for both Tcl 8.6 and 9.0. I only needed it to work on Unix like Standalone Bgexec but thought if AI is doing the work, I will get it to include Windows as well, as others may find it useful. I used Claude AI Sonnet 4.6. After going around in circles and a lot of testing, it produced something which I have managed to get working with CloudTk using Tcl 8.6 and 9.0.
This version doesn't include the session/tty option. I believe this is for controlling CLI programs similar to Expect.
To compile you need gcc available on your machine. Most Linux distribution have gcc but for Windows it is available from the BAWT site at https://www.tcl3d.org/bawt/download.html
Create a directory and download bgexec3-5.zip and unzip into the same directory. bgexec3-5.zip also has Critcl 3.3.1 included. Also download the Tclkits version you wish to compile with from the BAWT site at https://www.tcl3d.org/bawt/apps.html either Tcl 8.6 or Tcl 9.0. Copy the relevant Tclkit file that ends with "-tcl" to the same directory.
The bgexec man page is available here and also included in the bgexec3-5.zip file.
On Unix
~Tcl/Bgexec3-5$ ./tclkit-9.0.3-Linux64-intel-tcl critcl3.3.1.vfs/main.tcl -pkg bgexec.tcl
Config: linux-x86_64-gcc
Build: linux-x86_64-gcc
Target: linux-x86_64
Source: bgexec.tcl
(provide bgexec 3.5)
Library: bgexec.so
(tcl 9.0)
Stubs:
critcl/critcl_c/tcl9.0/tclDecls.h:
(tclStubsPtr => const TclStubs *tclStubsPtr;)
critcl/critcl_c/tcl9.0/tclPlatDecls.h:
(tclPlatStubsPtr => const TclPlatStubs *tclPlatStubsPtr;)
Package Placed Into: lib/bgexec
DoneOn Windows
PS C:\Tcl\Bgexec3-5> .\tclkit-9.0.3-win64-intel-tcl.exe .\critcl3.3.1.vfs\main.tcl -pkg .\bgexec.tcl
Config: win32-x86_64-gcc
Build: win32-x86_64-gcc
Target: win32-x86_64
Source: bgexec.tcl
(provide bgexec 3.5)
Library: bgexec.dll
(tcl 9.0)
Stubs:
critcl/critcl_c/tcl9.0/tclDecls.h:
(tclStubsPtr => const TclStubs *tclStubsPtr;)
critcl/critcl_c/tcl9.0/tclPlatDecls.h:
(tclPlatStubsPtr => const TclPlatStubs *tclPlatStubsPtr;)
Package Placed Into: lib/bgexec
DoneOn ARM (Raspberry Pi)
~Tcl/Bgexec3-5$ ./tclkit-8.6.17-Linux64-arm-tcl critcl3.3.1.vfs/main.tcl -pkg bgexec.tcl
Config: linux-aarch64-gcc
Build: linux-aarch64-gcc
Target: linux-aarch64
Source: bgexec.tcl
(provide bgexec 3.5)
Library: bgexec.so
(tcl 8.6)
Stubs:
critcl/critcl_c/tcl8.6/tclDecls.h:
(tclStubsPtr => const TclStubs *tclStubsPtr;)
critcl/critcl_c/tcl8.6/tclPlatDecls.h:
(tclPlatStubsPtr => const TclPlatStubs *tclPlatStubsPtr;)
Package Placed Into: lib/bgexec
DoneAll the files for the package are in the directory lib/bgexec.
Run the tests
On Unix ~/Tcl/Bgexec-3-5$ ./tclkit-9.0.3-Linux64-intel-tcl run_tests.tcl bgexec-basic.test ... ok (41/41) bgexec-combo.test ... ok (21/23) bgexec-combo2.test ... ok (70/70) bgexec-detach.test ... ok (16/16) bgexec-edge.test ... ok (43/43) bgexec-input.test ... ok (8/8) bgexec-io.test ... ok (31/31) bgexec-linebuf.test ... ok (14/14) bgexec-pipeline.test ... ok (13/13) bgexec-robustness.test ... ok (27/27) bgexec-stress.test ... ok (9/9) === Results: 295 run, 293 passed, 0 failed, 2 skipped === All tests passed. On Windows PS C:\Tcl\Bgexec3-5> .\tclkit-9.0.3-win64-intel-tcl.exe .\run_tests.tcl bgexec-basic.test ... ok (41/41) bgexec-combo.test ... ok (21/23) bgexec-combo2.test ... ok (70/70) bgexec-detach.test ... ok (14/16) bgexec-edge.test ... ok (41/43) bgexec-input.test ... ok (8/8) bgexec-io.test ... ok (31/31) bgexec-linebuf.test ... ok (14/14) bgexec-pipeline.test ... ok (13/13) bgexec-robustness.test ... ok (21/27) bgexec-stress.test ... ok (9/9) === Results: 295 run, 283 passed, 0 failed, 12 skipped === All tests passed. On ARM (Raspberry Pi) ~/Tcl/Bgexec3-5 $ ./tclkit-8.6.17-Linux64-arm-tcl run_tests.tcl bgexec-basic.test ... ok (41/41) bgexec-combo.test ... ok (21/23) bgexec-combo2.test ... ok (70/70) bgexec-detach.test ... ok (16/16) bgexec-edge.test ... ok (43/43) bgexec-input.test ... ok (8/8) bgexec-io.test ... ok (31/31) bgexec-linebuf.test ... ok (14/14) bgexec-pipeline.test ... ok (13/13) bgexec-robustness.test ... ok (27/27) bgexec-stress.test ... ok (9/9) === Results: 295 run, 293 passed, 0 failed, 2 skipped === All tests passed.
bgexec 3.5 Test Suite
A tcltest-based test suite for the bgexec Critcl package covering all features, bug regressions, platform-specific behaviour, and robustness across Tcl 8.6 and 9.0 on Linux (x86-64, ARM64) and Windows (x86-64).
Expected Test Results
| Platform | Run | Passed | Failed | Skipped |
| Linux x86-64 (8.6 + 9.0) | 295 | 293 | 0 | 2 |
| Linux ARM64 / Raspberry Pi (8.6 + 9.0) | 295 | 293 | 0 | 2 |
| Windows x86-64 (8.6 + 9.0) | 295 | 283 | 0 | 12 |
Skips are all intentional platform constraints — not failures:
- Linux/ARM: 2 skips — detach-7.1, detach-7.2 (use unix constraint, run fine on Unix but listed as skipped if test runner sees them on Windows)
- Windows: 12 skips — 6 original + 6 new Unix-only tests in bgexec-robustness.test (SIGTERM/SIGKILL explicit, signal-0, |& merge, 2> file redirect, ISO-8859-1 encoding)
Test files
| File | Tests | What it covers |
| bgexec-basic.test | 41 | Argument validation, basic execution, exit codes, option aliases, foreground path |
| bgexec-combo.test | 23 | Switch combinations: -onoutput+-onerror, kill via statVar, -ignoreexitcode, encoding with callbacks |
| bgexec-combo2.test | 70 | Extended switch combos: -lastoutputvariable, -updatevariable, large output with callbacks |
| bgexec-detach.test | 16 | Detached mode, statVar tracking, kill-by-write, callbacks, concurrent, Xvnc pattern |
| bgexec-edge.test | 43 | Edge cases: empty output, binary data, pipeline exit codes, re-entrancy, rapid exit |
| bgexec-input.test | 8 | -input writable pipe to child stdin |
| bgexec-io.test | 31 | stdout/stderr collection, -keepnewline, callbacks, redirects, large output |
| bgexec-linebuf.test | 14 | -linebuffered with fast/slow writers, line integrity, detached mode, signal detection |
| bgexec-pipeline.test | 13 | Multi-stage pipelines, early-exiting middle stage, -input with pipeline, concurrency stress |
| bgexec-robustness.test | 27 | -killsignal, -environ, 2>@1 merge, encoding (binary/keepnewline/ISO-8859-1), re-entrancy |
| bgexec-stress.test | 9 | Sequential/concurrent fd-leak detection, 1000-line integrity, kill cycles, interleaved |
| Total | 295 |
Jeff Smith 2026-04-19 : Enhanced Standalone Bgexec now at 3.5. Redesigned the Test Suite and now 295 tests which highlighted a lot of bugs especially with the way Claude AI wrote the Windows implementation.