#1638 tcl script that writes to stdout and is called from wish thr

obsolete: 8.4.4
closed
75. wish (49)
5
2011-01-17
2003-12-19
No

A tcl script that writes to stdout and is called from wish
through exec does not return but just sits there and
consumes CPU cycles. This occurs when wish is started
by double clicking in the finder. The problem does not
occur when wish is started from the terminal like this:

$ /Applications/Utilities/Wish
Shell.app/Contents/MacOS/Wish Shell

To illustrate the problem, look at the following two little
scripts a.tcl and b.tcl:

a.tcl:
---------------------------------
#!/bin/sh
# the next line restarts using tclsh \ exec tclsh "$0" ${1+$@}

if [catch {exec [file join [file dirname [info script]]
b.tcl]} error] {
puts stderr $error
}

puts "end of a.tcl"
---------------------------------

b.tcl:
---------------------------------
#!/bin/sh
# the next line restarts using tclsh \ exec tclsh "$0" ${1+$@}

puts "end of b.tcl"
---------------------------------

When "a.tcl" is called from the command line the output
is

end of a.tcl

as expected. But when "a.tcl" is sourced from Wish
(either by source a.tcl or by using wish's menu item)
b.tcl gets called but never returns. It seems to be
related to the called script writing to stdout/stderr;
when the puts in "b.tcl" is removed everything works as
expected.

Calling tclsh directly by putting "#!/usr/bin/tclsh" in the
first line instead of calling indirectly through sh does not
solve the problem.

I am using Daniel Steffen's BI distribution of Tcl/Tk 8.4.4
on Mac OS X 10.3.1!

Discussion

  • Don Porter
    Don Porter
    2004-03-30

    • labels: 394429 --> 75. wish
     
  • Kevin Walzer
    Kevin Walzer
    2011-01-17

    • status: open --> closed