0

我们的应用程序已tcl嵌入其中并使用starkit; tk静态链接到其中。

当我运行应用程序时,gui会出现并响应所有键,但是当我点击ctrl+d终止时它会挂起。我在帖子末尾给出了挂起的回溯。

首先让我描述一下我们是如何嵌入Tcl/Tk到我们的应用程序中的。

#--------------------------------------------------------------
# (*) 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

我们需要tk没有真正的字体,因为它会使应用程序崩溃tk要从我们需要编译的源安装tcl:(我不知道如何编译指向 Active-Tcl 目录。如果tk--with-tcl选项请告诉我)

#--------------------------------------------------------------
# (*) 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

gmake installtcl因为我们需要保留 ActiveTcl 的 tclsh。接下来安装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

现在我使用以下命令运行我的应用程序gdb

% gdb rs
% r -gui

我击中ctrl+d了导致挂起的原因,它给出了以下回溯。有人可以帮我解决这个问题吗?

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
4

1 回答 1

4

好吧,终端将Ctrl+D解释为 EOF 指示符,这意味着stdin通道(在 Tcl 级别)现在将处于 EOF 状态。那么问题是你的代码将如何响应它。在那里很难说任何通用的东西,因为您可以编写 Tcl 代码来完全定制那种东西。

但是,我(从您的堆栈跟踪)看到您vwait正在使用一个(即自定义事件循环)。我想问题是因此您的代码没有正确响应 EOF 并且使用exit或导致循环终止。要检测到这一点,您需要设置一个可读fileeventstdin,尝试从该通道读取(到目前为止正常);如果读取失败,请检查 EOFeof并采取适当的措施……</p>

于 2012-05-19T08:09:52.697 回答