TICKIT_WATCH_SIGNAL(3)

πŸ’– tickit_watch_signal β€” bestie edition πŸ’–

okay so this one lives in the Library Functions Manual (yes that's the manual name, we're fancy now) and it's literally about making your code go "omg a signal!!!" and do a little callback dance πŸ’…


🌸 NAME 🌸

tickit_watch_signal β€” invoke a callback when a POSIX signal is raised ✨


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <tickit.h>

typedef int TickitCallbackFn(Tickit *t, TickitEventflags flags,
    void *info, void *user);

void *tickit_watch_signal(Tickit *t, int signum, TickitBindFlags flags,
    TickitCallbackFn *fn, void *user);

Link with -ltickit. 🫢


πŸŽ€ DESCRIPTION πŸŽ€

so basically tickit_watch_signal() is the way you sign a callback function up to get pinged by the toplevel event loop whenever a POSIX signal gets received by the process. no cap. πŸ“‘

a registered callback gets invoked by a running call to tickit_run(3). and listen β€” the callback can get invoked more than once if the signal is received multiple times. it's giving "not me showing up again." 😭

the info pointer? it will be NULL. that's it, that's the tea. πŸ“


🌈 multiple registrations, one signal (yes queen, you can stack them)

multiple registrations may be made for the same signal number. when that signal comes through, all of them get invoked, in the order they exist in the queue. so it's a whole little lineup. πŸ‘‘

now here's the vibe check on ordering:

  • if you registered with the TICKIT_BIND_FIRST flag, the callback gets inserted at the start of the queue, coming before the others. main character energy, front of the line. ⭐
  • if not, it's appended at the end. no shame in that, still valid, still iconic. πŸ’œ

πŸ™ˆ what happens if you cancel

if it gets cancelled by tickit_watch_cancel(3), the callback function is invoked with just the TICKIT_EV_UNBIND flag β€” but only if it had been registered with TICKIT_BIND_UNBIND. otherwise, nothing. don't @ me, that's just how it works. πŸ’€


✨ RETURN VALUE ✨

tickit_watch_signal() returns an opaque identifier pointer. yep. opaque. mysterious. we love a secretive little guy. πŸ”₯


πŸ‘‘ SEE ALSO πŸ‘‘


and that's the whole page bestie!! 🌸 this was TICKIT_WATCH_SIGNAL(3) from the Library Functions Manual, and yeah it's got that same TICKIT_WATCH_SIGNAL(3) energy at the bottom too. go raise some signals responsibly. mwah πŸ’…βœ¨