stsignal(3)

✨ stsignal(3) ✨

okay so bestie, we're in the ShapeTools Toolkit Library manual, third section, and this whole page is about signal handling πŸ’… like, catching interrupts so your program doesn't just yeet itself into the void mid-temp-file. it's giving "responsible adult" energy and honestly? we love that for us 🫢


🌸 NAME 🌸

stCatchSigs, stInterruptAction, stQuitAction, stTermAction, stCleanup, stExit β€” signal handling πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <config.h>
#include <sttk.h>

void stCatchSigs (void);

Sfunc_t(*stInterruptAction)();

Sfunc_t(*stQuitAction)();

Sfunc_t(*stTermAction)();

void stCleanup (void);

void stExit (int exitCode);

no cap, that's the whole vibe right there ↑


πŸ’– DESCRIPTION πŸ’–

stCatchSigs activates a bunch of interrupt handlers, and here's the tea: they're defined internally in the ShapeTools toolkit library. like, you don't write them, the library already did πŸ‘‘

handlers get set up for these signals, periodt:

  • SIGINT
  • SIGQUIT
  • SIGFPE
  • SIGBUS
  • SIGSEGV
  • SIGTERM

⚠️ important: all of the interrupt handlers, except the one for SIGINT, cause program termination after having done some cleanup work. so yeah, the program is ending, but at least it's ending tidy ✨

and what is that cleanup, you ask? it's removing all temporary files by calling stRmRegisteredFiles(3). iconic behaviour honestly, cleaning up after yourself is main character energy πŸ§ΉπŸ’…


πŸŽ€ the customizable ones πŸŽ€

some of the signal handlers are capable of executing functions defined by the application while they're handling the interrupt. it's not automatic though β€” you activate this mechanism by assigning a function's address to the appropriate variable. iykyk 😌

here's the complete list, no skips, no cuts:

  • SIGINT β†’ stInterruptAction
  • SIGQUIT β†’ stQuitAction
  • SIGTERM β†’ stTermAction

that's it, that's the whole list bestie πŸ’œ


🌈 the cleanup girlies 🌈

stCleanup calls stRmRegisteredFiles(3) to remove all temporary files, and also calls the AtFS function af_cleanup(3) β€” which orders AtFS's affairs. like, getting AtFS's whole life together fr fr πŸ¦‹

stExit does the same as stCleanup, and additionally ends the program execution, returning exitCode. so it's the cleanup + the dramatic exit πŸšͺ✨

heads up: if you're handing stExit an exitCode, that value is what the program hands back when it dips. keep it in mind 🌸

⭐ SEE ALSO ⭐


and that's the whole page bestie!! πŸŽ€ this one came out of sttk-1.7, dated Thu Jun 24 17:43:32 1993 β€” yeah, it's vintage, it's retro, it's lowkey older than everyone in the group chat, and it still ate πŸ’…βœ¨ mwah, love u, go catch some signals responsibly πŸ«ΆπŸ’–

πŸ“¦ where this page comes from