Tcl Source Code

View Ticket
Login
2026-10-17
07:12 • Ticket [2982713fff] I cannot run exec command on Linux using Tcl/Tk status s... artifact: 47d116aa41 user: serhiy.storchaka
07:11
Fix [2982713fff]: if tclsh was started with SIGCHLD ignored (e.g. from system() in a program which i... check-in: b3c28a91a0 user: serhiy.storchaka tags: tclsh-inherited-sigchld
2010-04-07
22:41 • Ticket [2982713fff] I cannot run exec command on Linux using Tcl/Tk status s... artifact: 7114c167ca user: ferrieux
21:33 • Ticket [2982713fff]: 4 changes artifact: 2eee5a27a0 user: ferrieux
21:01 • Ticket [2982713fff]: 4 changes artifact: 104a7d7a90 user: dgp
20:59 • Add attachment test.log to ticket [2982713fff] artifact: f961156674 user: rkanherkar
20:59 • Ticket [2982713fff] I cannot run exec command on Linux using Tcl/Tk status s... artifact: 76e535d789 user: rkanherkar
20:59 • Ticket [2982713fff]: 4 changes artifact: a689c52278 user: rkanherkar
20:59 • Add attachment testcase.log to ticket [2982713fff] artifact: a1aa7a18a0 user: rkanherkar
20:55 • Ticket [2982713fff] I cannot run exec command on Linux using Tcl/Tk status s... artifact: 4adb5fcee6 user: rkanherkar
2010-04-06
23:24 • Ticket [2982713fff]: 4 changes artifact: 92cae90235 user: ferrieux
15:39 • New ticket [2982713fff]. artifact: 3ba8456ad9 user: rkanherkar

Ticket UUID: 2982713
Title: I cannot run exec command on Linux using Tcl/Tk
Type: Bug Created on: 2010-04-06 15:39:59
Submitter: rkanherkar Assigned to: nobody
Subsystem: 69. Other Severity:
Priority: 5 Medium Last modified: 2026-10-17 07:12:30
Status: Open Closed by:
Resolution: None Closed on:
Version: 8.6.18, 9.0.5, 9.1.0
Description:
I have created the script :
set log [open /home/rkanherk/iona_linux/demos/OrbixSSL/securebank.BMC/cxx/testcase.log w]
puts $log "Before"
set rc [catch {exec date} retval]
puts $log "rc=$rc retval=$retval"
puts $log "After"
close $log


My application calls this script and in the log i get the following signal error :


error waiting for process to exit: child process lost (is SIGCHLD ignored or trapped?)


Investigation shows that exec function in Tcl on Linux does not work .
User Comments:
ferrieux added on 2010-04-06 23:24:05:
Cannot reproduce. Please give details:
   - Tcl version
   - whether you recompiled it or got it in binary form
   - compile/configure options if applicable
   - Linux distribution, kernel version
   - attach the output of:

     strace -f -tt -T -o file ./tclsh myscript.tcl

rkanherkar added on 2010-04-07 20:55:13:
Hi,

I am using the 8.4 version of Tcl/Tk on Linux m/c whose details are :
Linux vm-lnx-rds18 2.6.18-128.el5 #1 SMP Wed Dec 17 11:42:39 EST 2008 i686 i686 i386 GNU/Linux

I have using Tcl in the binary format in which I got it.I did not compile it.

If you simply try to run the script I provided then you will not get the problem.But you will face the problem when u try to run it from some different application.

Like for example I am calling this Tcl script using system command in orbix application.

I have attached the testcase.log and test files.Test file contains the required trace output.

rkanherkar added on 2010-04-07 20:59:02:

File Added - 369745: testcase.log

rkanherkar added on 2010-04-07 20:59:44:

File Added - 369746: test.log

dgp added on 2010-04-07 21:01:38:
If this is a problem in a program that embeds the
Tcl library, make sure that program is properly
initializing Tcl.  Check for calls to Tcl_FindExecutable()
and Tcl_Init().  If you are not the author of the
failing program, report the issue to them instead/in addition
to here.

ferrieux added on 2010-04-07 21:33:25:
Roma, by "calling this Tcl script using system command in
orbix application", I suspect you mean system("tclsh thescript.tcl"), right ?

If yes, then please attach the contents of the 'file' file when prepending that line with the strace command:

  system("strace -f -tt -T -o file tclsh myscript.tcl")

ferrieux added on 2010-04-07 22:41:08:
Ah never mind, I managed to simulate the problem with just "sh":

 # sh
 $ trap "" CHLD
 $ tclsh
 % exec echo yo
 yo
 error waiting for process to exit: child process lost (is SIGCHLD ignored or trapped?)
 %

This shows that when the parent process (sh or Orbix) manipulates the sigmask so as to block SIGCHLD, bad things happen, in _any_ software that spawns children, like Tcl or any shell. So I 'd say this is a Don't Do That case. Please report the problem to Orbix.

serhiy.storchaka added on 2026-10-17 07:12:30:

Reproduced when tclsh is started with SIGCHLD ignored, as by system() from a program which ignores it, or env --ignore-signal=CHLD tclsh: the kernel reaps the children itself and waitpid() fails with ECHILD. Proposed fix in branch tclsh-inherited-sigchld: Tcl_MainEx() restores the default SIGCHLD handling if it is ignored. Applications which embed Tcl keep their own setting, as Tk now keeps the signal handlers of the embedding application on macOS (Tk 989b1ccb98). Test exec-24.1.


Attachments: