san wrote:
> Hi guys,
>
> I am developing Tcl extension for signals.
> I am having problem with the Tcl_AsyncCreate/Tcl_AsyncMark. My code is
> as below:
>
> handler(int sig)
> {
> Tcl_AsyncMark(token);
> }
>
> addsignal(sig)
> {
> ...
> Tcl_asynchandler token;
> token = Tcl_AsyncCreate( handler_safe, (ClientData)&sig);
> ....
> sigaction sa;
> sa.sa_handler = handler;
> }
>
> handler_safe(ClientData cd, Tcl_Interp *interp, int code)
> {
> ... handle the signal ....
> }
>
> If a signal occurs token should be set by handler and handler_safe will
> be executed if in safe state.
> I have a problem here. token is being set but handler_safe is not being
> called at proper place...
>
>
> What could be the problem. Please Help..
>
The AsyncProc will be called by Tcl at the border of bytecoded blocks
for an active Tcl_Eval* or immediately if the Tcl thread is idle in the
event loop. What is the proper place you want the handler to be called
at? By design, the thread that called addsignal() will be the same one
to to call handler_safe(). Hopefully that's the thread you run Tcl
from. The thread that calls handler() can be any thread, btw.
Received on Sun Apr 30 02:17:02 2006