killing TCL/tk process in Windows batch file

42 views
Skip to first unread message

dr.mt...@gmail.com

unread,
May 17, 2024, 4:46:18 PMMay 17
to Shen
This is maybe the last non-Shen challenge in Shen/tk
and involves ending a process cleanly.  I'm copying
to this to Stackoverflow. This batch file

START /B sbcl-shen.exe
C:\ActiveTcl\bin\wish.exe "C:\Users\shend\OneDrive\Desktop\Shen\S38.3\StLib\Tk\root.tcl"

starts Shen/SBCL and allows the TCL/tk event loop in root to
kick in.  Everything seems to be peachy until I kill my application by 
exiting Shen and killing the root window.   

However a look at the task manager shows there is a TCL process
still running and this has to be killed lest it screw up the next session.
I'm having to kill this process in the task manager.  The question is - is there
a command that can be placed in the batch file to do what I have to do
in the task manager?

Mark

Bruno Deferrari

unread,
May 17, 2024, 5:10:34 PMMay 17
to qil...@googlegroups.com
What are the contents of root.tcl? Maybe you need to somehow specify that the window is the main program window? or set up some hook when it gets closed so that the program exits?

--
You received this message because you are subscribed to the Google Groups "Shen" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qilang+un...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/qilang/449982a2-bb48-4bf1-81b5-8a97f5ddd789n%40googlegroups.com.


--
BD

Bruno Deferrari

unread,
May 17, 2024, 5:16:12 PMMay 17
to qil...@googlegroups.com
This works for me:

proc on_close {} {

    exit

}

set mainWindow .

# With this line it works, without it wish doesn't exit

wm protocol $mainWindow WM_DELETE_WINDOW on_close

label .label -text "Test"

pack .label

vwait forever

--
BD

Bruno Deferrari

unread,
May 17, 2024, 5:16:57 PMMay 17
to qil...@googlegroups.com
https://www.tcl.tk/man/tcl8.6/TkCmd/wm.htm#M58 forgot the link, "wm protocol" is explained here
--
BD

dr.mt...@gmail.com

unread,
May 18, 2024, 4:14:31 AMMay 18
to Shen
I think the problem is that the root window
is a separate process to the TCL event loop.
Hence killing the Tk window does not kill the
event loop nor does killing Shen.   

I've found that to have a clean shutdown I have
had to program a function tk.exit in Shen to order the
event loop to end.  So the pattern is

(tk.exit)
 close down the Tk and Shen windows.  

Mark
Reply all
Reply to author
Forward
0 new messages