|
|
 |
 |
 |
 |
TCL(Tool Command Language) Scripting
|
 |
 |
 |
 |
 |
 |
 |
 |
Howto break running tcl script (Tcl_EvalFile)?
Hi, Suppose we have program which has internal tcl scripter and should be exited regardless of running tcl script, or should have possibility to break running script. Is there any possibility to break Tcl_EvalFile execution? Bogdan
On 11 Mai, 09:41, Bogdan Slusarczyk <bodzio@op.pl> wrote: > Hi, > Suppose we have program which has internal tcl scripter and should be > exited regardless of running tcl script, or should have possibility to > break running script. Is there any possibility to break Tcl_EvalFile > execution?
In [source] it is possible to terminate evaluation with [return]. I suppose it's the same in Tcl_EvalFile.
> In [source] it is possible to terminate evaluation with [return]. I > suppose it's the same in Tcl_EvalFile.
Do you mean that I can break Tcl_EvalFile by using [return] from tcl script? But I want to break script execution at tcl engine level (c/c++).
On 11 Mai, 10:40, Bogdan Slusarczyk <bodzio@op.pl> wrote: > > In [source] it is possible to terminate evaluation with [return]. I > > suppose it's the same in Tcl_EvalFile. > Do you mean that I can break Tcl_EvalFile by using [return] from tcl > script? But I want to break script execution at tcl engine level (c/c++).
Yes - my point was to put a [return] into the script you pass to Tcl_EvalFile, see whether that helps.
>>> In [source] it is possible to terminate evaluation with [return]. I >>> suppose it's the same in Tcl_EvalFile. >> Do you mean that I can break Tcl_EvalFile by using [return] from tcl >> script? But I want to break script execution at tcl engine level (c/c++). > Yes - my point was to put a [return] into the script you pass to > Tcl_EvalFile, see whether that helps.
That will not work, I cannot control script syntax :(
Richard Suchenwirth wrote: > In [source] it is possible to terminate evaluation with [return]. I > suppose it's the same in Tcl_EvalFile.
It's exactly the same because [source] is a very thin layer over Tcl_EvalFile to expose that function to scripts. Donal.
Bogdan Slusarczyk wrote: > Suppose we have program which has internal tcl scripter and should be > exited regardless of running tcl script, or should have possibility to > break running script. Is there any possibility to break Tcl_EvalFile > execution?
There are some possibilities. However, to correctly determine what you need, we need a few more details. In particular, we need to know what you expect to trigger the termination of the script (e.g. is it a signal, a message from another thread, some kind of callback within the same thread?) Do you instead want to set a timeout for the execution of the script (something which is easily done with new features in Tcl 8.5)? Donal.
> There are some possibilities. However, to correctly determine what you > need, we need a few more details. In particular, we need to know what > you expect to trigger the termination of the script
I want just break Tcl_EvalFile from c/c++. Suppose that someone runs script with while {1} {} - I just want to break this execution. It can return error, or any status, it can throw excpetion (as long as it's safe) - it doesn't matter. Breaking can take some time, but I have to be sure that script execution will be finished.
Bogdan Slusarczyk wrote: >> There are some possibilities. However, to correctly determine what you >> need, we need a few more details. In particular, we need to know what >> you expect to trigger the termination of the script > I want just break Tcl_EvalFile from c/c++. Suppose that someone runs > script with while {1} {} - I just want to break this execution. It can > return error, or any status, it can throw excpetion (as long as it's > safe) - it doesn't matter. Breaking can take some time, but I have to be > sure that script execution will be finished.
Hi, well lets thing about you are on a single processor host and no threads are available: the control flow is !in! the tcl-script or !out-of! the tcl script. If you are "out-of" a tcl script in "C" you have allready stopped the tcl script. - you want to !delete! the tcl script and the control flow is in the "C" code -> the C have have to be called from in-site the tcl script this is done usually by an binary extension or an event-handler: and this extension can stop the tcl-script from above just by return TCL_ERROR (in case if no catch is available) or you can call "Tcl_Exit" (man Tcl_Exit) to kill the whole Application or "Tcl_ExitThread" this will kill the current thread. If you have the "interp" structure available you can delete the whole interp "Tcl_DeleteInterp" and let the application (in C) running mfg Andreas
Bogdan Slusarczyk schrieb: >> There are some possibilities. However, to correctly determine what you >> need, we need a few more details. In particular, we need to know what >> you expect to trigger the termination of the script > I want just break Tcl_EvalFile from c/c++. Suppose that someone runs > script with while {1} {} - I just want to break this execution. It can > return error, or any status, it can throw excpetion (as long as it's > safe) - it doesn't matter. Breaking can take some time, but I have to be > sure that script execution will be finished.
As someone here as hinted already there are two ways: - do the tcl stuff in another thread. then you can terminate the thread at your leisure - start tcl in a different process and pass stuff with sockets. That wrapper can be a bit complicated but then you can kill the process any time A third possibility may be to use tcls debugging capabilities but i have no idea what they are and how to use them. Lots of Greetings! Volker -- For email replies, please substitute the obvious.
|
 |
 |
 |
 |
|