exec on windows oddity?

MHo, 2009, June 20.:

Example-1:

         tk_messageBox -message "before"
         exec -- [auto_execok cmd] << {
                 notepad
                 sleep 5
         } &
         tk_messageBox -message "after"

With example-1, everything works as expected:

  1. the start message appears - it has to be confirmed
  2. notepad starts (this by itself is an asynchron process)
  3. sleep starts (because thats a console mode program, a separate console window appears)
  4. the stop message appears immediately (because the whole cmd is started in background with &)
  5. after 5 seconds sleep ends
  6. notepad is still running

The main window of the tk prog stays responsive all the time, because of exec ... &.


Example-2:

         tk_messageBox -message "before"
         exec -- [auto_execok cmd] << {
                 notepad
                 sleep 5
         }
         tk_messageBox -message "after"

With example-2, things are slightly different:

  1. the start message appears - it has to be confirmed, same as above
  2. notepad starts, same as above
  3. sleep starts, same as above
  4. after 5 seconds sleep ends
  5. notepad is still running

At this point, the stop message still doesn't pop up, which is at first thought correct, because exec works in synchronous mode (without &). But: notepad has started in the background (so this step has finished), sleep has started and finished after 5 seconds, so why does exec not comes to an end??? The main program (at least its main window) seems to be in some indifferent state somewhere within the exec step, receiving input (windows goes to foreground) but does not redraw itself anymore, soon becoming an empty white box if obscured by other windows etc...

Only after closing notepad, the end message appears, and everything continues the normal way.


Addition, 2010-10-28 MHo:

Starting console mode applications from tclsh with exec doesn't always work. If I start e.g. the Hessling Editor (THE), that editor complains about wrong console dimensions. If I start a powerbasic console mode program which displays the console dimensions, it shows rows x cols = 1 x 65473. Resetting those dimension fails. The solution to this particular problem was to start a win32-mode-wrapper-program which in turn starts THE. This works, because when win32 starting console mode apps via windows mechanisms, a new console is created (I think). I know the problems are discussed elsewhere here on the wiki, and I left some comments on some pages before... I think, exec needs some more switches to control such things at least on ms windows.