Tcl_CreateCloseHandler(3)

πŸ“¦
version 9.0.3 Β· 2 versions
, in alpine 3.23, alpine 3.24, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable

✨ Tcl_CreateCloseHandler ✨

okay bestie, we're looking at the Tcl Library Procedures page for Tcl_CreateCloseHandler and Tcl_DeleteCloseHandler β€” it's giving "set up callbacks for when channels get closed" and honestly? iconic. πŸ’…


🌸 NAME 🌸

Tcl_CreateCloseHandler, Tcl_DeleteCloseHandler β€” arrange for callbacks when channels are closed πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <tcl.h>

Tcl_CreateCloseHandler(channel, proc, clientData)

Tcl_DeleteCloseHandler(channel, proc, clientData)

πŸ’– ARGUMENTS πŸ’–

  • Tcl_Channel channel (in) β€” the channel you wanna create or delete a close callback for, no cap 🫢
  • Tcl_CloseProc *proc (in) β€” the procedure that gets called as the callback, literally the whole point ✨
  • void *clientData (in) β€” an arbitrary one-word value you pass along to proc πŸŽ€

πŸ‘‘ DESCRIPTION πŸ‘‘

so here's the tea, bestie: Tcl_CreateCloseHandler arranges for proc to be called when channel is closed β€” and we mean closed with Tcl_Close or Tcl_UnregisterChannel, or by using the Tcl close command. 🌈

Your proc should match this prototype, exactly, character for character:

typedef void Tcl_CloseProc(
        void *clientData);

the clientData you get in there is the same value you handed over in the call to Tcl_CreateCloseHandler. same one, fr fr. πŸ’œ

Tcl_DeleteCloseHandler removes a close callback for channel. the proc and clientData together are what identify which close callback to remove β€” that's the vibe check that decides who gets yeeted. πŸ™ˆ

⚠️ heads up: Tcl_DeleteCloseHandler does nothing if its proc and clientData arguments do not match the proc and clientData for a close handler for channel. like, nothing nothing. it just stands there. πŸ’€

πŸ”₯ SEE ALSO πŸ”₯


⭐ KEYWORDS ⭐

callback, channel closing


and that's the whole page, bestie β€” go forth and handle those closes πŸ’…

this one's from the Tcl library docs, version 7.5, and the date stamp is 7.5 too, so yeah, it's been around a minute and it still ate. periodt. πŸŽ€πŸ’–βœ¨

πŸ“¦ where this page comes from