Tcl_Cancel(3tcl)
Tcl_Cancel β the manual page, bestie edition π
okay so this is straight out of the Tcl Library Procedures manual, and it's literally all about canceling Tcl scripts. two functions, one mission: make the script STOP. π
β¨ NAME β¨
Tcl_CancelEval, Tcl_Canceled β cancel Tcl scripts. that's it, that's the whole vibe. π
πΈ SYNOPSIS πΈ
#include <tcl.h>
int
Tcl_CancelEval(interp, resultObjPtr, clientData, flags)
int
Tcl_Canceled(interp, flags)
π ARGUMENTS π
Tcl_Interp *interp(in) β the interpreter where we're canceling the script. it's giving "which one of y'all is getting stopped" energy.Tcl_Obj *resultObjPtr(in) β the error message to use in the cancellation, orNULLif you want a default message instead. and heads up: if it's notNULL, this object gets its reference count decremented beforeTcl_CancelEvalreturns. so keep an eye on it, fr.int flags(in) β an OR'ed combo of flag bits for extra options. forTcl_CancelEval, onlyTCL_CANCEL_UNWINDis currently supported. forTcl_Canceled, onlyTCL_LEAVE_ERR_MSGandTCL_CANCEL_UNWINDare currently supported.void *clientData(in) β rn this is reserved for future use, so just set it toNULLand move on. it's not doing anything yet, no cap. π
π¦ DESCRIPTION π¦
Tcl_CancelEval cancels or unwinds whatever script is in progress, and it does it soon after the next invocation of asynchronous handlers β which makes TCL_ERROR the return code for that script. and the iconic part? this function is thread-safe, so you can call it from any thread in the process. main character energy across every thread. π
Tcl_Canceled checks whether the script in progress has been canceled, and returns TCL_ERROR if it has. otherwise you get TCL_OK back. extensions can use this to check whether they should bail out of a long running command β lowkey essential if you don't want your command just sitting there forever. but this one is thread sensitive, and it may only be called from the thread the interpreter was created in. respect the thread, bestie. π§΅
β FLAG BITS β
any OR'ed combination of these values can be used for the flags argument to procedures such as Tcl_CancelEval:
TCL_CANCEL_UNWINDβ this flag is used byTcl_CancelEvalandTcl_Canceled. forTcl_CancelEval, if this flag is set, the script in progress is canceled and the evaluation stack for the interpreter is unwound. forTcl_Canceled, if this flag is set, the script in progress is considered canceled only if the evaluation stack for the interpreter is being unwound. context matters, periodt. β¨TCL_LEAVE_ERR_MSGβ onlyTcl_Canceleduses this one; every other procedure ignores it. if an error is returned and this bit is set inflags, then an error message gets left in the interpreter's result, where you can retrieve it withTcl_GetObjResultorTcl_GetStringResult. if this flag bit is not set, then no error message is left and the interpreter's result will not be modified. so it's the "do you want the receipts or not" flag. π§Ύ
π«Ά REFERENCE COUNT MANAGEMENT π«Ά
Tcl_CancelEval always decrements the reference count of its resultObjPtr argument (if that's non-NULL). it's expected to usually be called with an object that has a zero reference count. but if the object is shared with some other location (including the Tcl evaluation stack), it should have its reference count incremented before you call this function. this is the part where you double-check before you hit go, i promise. π
π SEE ALSO π
π KEYWORDS π
cancel, unwind
and that's the whole page, bestie. this one's from Tcl version 8.6, filed under Tcl_Cancel(3tcl) β go forth and cancel responsibly. slay. π
β¨π¦
π¦ where this page comes from
- ubuntu questing: tcl9.0-doc 9.0.2+dfsg-1
- ubuntu resolute: tcl9.0-doc 9.0.3+dfsg-1
- ubuntu stonking: tcl9.0-doc 9.0.4+dfsg-1
- Copyright (c) 2006-2008 Joe Mistachkin
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms