Reputation: 1122
Our application has tcl
embedded in it and by usingstarkit
; tk
is statically linked into it.
When I run the application, gui
comes up and responds to all keys but when I hit ctrl+d
to terminate it hangs. I have given the back trace of the hang at the end of the post.
First let me describe how we are embedding Tcl/Tk
in our application.
#--------------------------------------------------------------
# (*) install ActiveTcl
# we need starkit and ActiveTcl tclsh is batteries included
#--------------------------------------------------------------
% tar -xzf ActiveTcl8.5.8.1.291945-linux-x86_64-threaded.tar.gz
% cd ActiveTcl8.5.8.1.291945-linux-x86_64-threaded
# specify /a/b/tcltk8.5.8/linux26_x86_64 as install dir in gui
% ./install.sh
We need tk
without true type fonts since it was crashing the application. To install tk
from sources we need tcl
compiled: (I do not know how to compile tk
with --with-tcl
pointing to Active-Tcl directory. If there is an option please let me know)
#--------------------------------------------------------------
# (*) install tcl from sources
#--------------------------------------------------------------
% tar -xzf tcl8.5.8-src.tar.gz
% cd tcl8.5.8/unix
% ./configure --prefix=/a/b/tcltk8.5.8/linux26_x86_64 \
--enable-shared=no \
--enable-threads
% gmake
NO gmake install
for this tcl
since we need to retain tclsh of ActiveTcl. Next install tk
.
#--------------------------------------------------------------
# (*) install tk from sources
# need to disable xft (true type font) set --disable-xft
#--------------------------------------------------------------
% tar -xzf tk8.5.8-src.tar.gz
% cd tk8.5.8/unix
% ./configure --prefix=/a/b/tcltk8.5.8/linux26_x86_64 \
--enable-shared=no \
--with-tcl=/a/b/tcltk8.5.8/src/tcl8.5.8/unix \
--disable-xft \
--enable-threads
% gmake
% gmake install
Now I am run my application using gdb
:
% gdb rs
% r -gui
I hit ctrl+d
which causes the hang and it gives the following back trace. Can someone help me fix this problem?
Program received signal SIGINT, Interrupt.
[Switching to Thread 182897358720 (LWP 9535)]
0x0000003739608b3a in pthread_cond_wait@@GLIBC_2.3.2 ()
from /lib64/tls/libpthread.so.0
(gdb) bt
#0 0x0000003739608b3a in pthread_cond_wait@@GLIBC_2.3.2 ()
from /lib64/tls/libpthread.so.0
#1 0x0000000001833e22 in Tcl_ConditionWait ()
#2 0x0000000001834d41 in Tcl_WaitForEvent ()
#3 0x00000000017fec68 in Tcl_DoOneEvent ()
#4 0x00000000017cb4ad in Tcl_VwaitObjCmd ()
#5 0x000000000178b6ec in TclEvalObjvInternal ()
#6 0x00000000017cd08d in TclExecuteByteCode ()
#7 0x00000000017d5798 in TclCompEvalObj ()
#8 0x000000000178d6ac in TclEvalObjEx ()
#9 0x00000000017939c4 in Tcl_CatchObjCmd ()
#10 0x000000000178b6ec in TclEvalObjvInternal ()
#11 0x00000000017cd08d in TclExecuteByteCode ()
#12 0x00000000017d5a84 in Tcl_ExprObj ()
#13 0x000000000178c3e3 in Tcl_ExprBooleanObj ()
#14 0x0000000001796704 in Tcl_IfObjCmd ()
#15 0x000000000178b6ec in TclEvalObjvInternal ()
#16 0x000000000178cee6 in TclEvalEx ()
#17 0x000000000178d616 in Tcl_EvalEx ()
#18 0x00000000017f1be9 in Tcl_FSEvalFileEx ()
#19 0x000000000179c385 in Tcl_SourceObjCmd ()
#20 0x000000000178b6ec in TclEvalObjvInternal ()
#21 0x000000000178cee6 in TclEvalEx ()
---Type <return> to continue, or q <return> to quit---
#22 0x000000000178d616 in Tcl_EvalEx ()
#23 0x000000000178d9d8 in TclEvalObjEx ()
#24 0x000000000180d45f in Tcl_UplevelObjCmd ()
#25 0x000000000178b6ec in TclEvalObjvInternal ()
#26 0x00000000017cd08d in TclExecuteByteCode ()
#27 0x000000000180e4cd in TclObjInterpProcCore ()
#28 0x000000000178b6ec in TclEvalObjvInternal ()
#29 0x000000000178cee6 in TclEvalEx ()
#30 0x000000000178d616 in Tcl_EvalEx ()
#31 0x000000000178dacd in Tcl_Eval ()
#32 0x00000000008f26aa in xrAppPlatformInit (interp=0x211a410)
at xrAppPlatform.c:430
#33 0x00000000017f69ca in Tcl_Main ()
#34 0x00000000008f2153 in xrMain (argc=3, argv=0x20fe880)
at xrAppPlatform.c:177
#35 0x00000000008f1092 in main (argc=2, argv=0x7fbfffe718) at main.cpp:213
Upvotes: 0
Views: 252
Reputation: 137567
Well, the Ctrl+D is interpreted by the terminal as an EOF indicator, which means that the stdin
channel (at the Tcl level) will now be in an EOF state. The question then is how is your code going to be responding to that. It's very hard to say anything generic there, as you can write Tcl code to completely customize that sort of thing.
However, I see (from your stack trace) that you have a vwait
in use (i.e., a custom event loop). I guess that the problem is therefore that your code isn't reacting to the EOF correctly and either using exit
or causing the loop to terminate. To detect this, you need to set a readable fileevent
on stdin
which tries to read from that channel (so far so normal); if the read fails, check for EOF with eof
and take appropriate action…
Upvotes: 4