S6-FTRIGW(7)

πŸ“¦ version 2.15.1.0, in nixpkgs unstable

πŸ’– s6-ftrigw(7) β€” the notifier API, bestie edition πŸ’–

okay so this one lives in the Miscellaneous Information Manual, and it's page S6-FTRIGW(7) β€” say hi πŸ‘‹

✨ NAME ✨

s6-ftrigw β€” the API for notifiers, aka programs that just wanna regularly announce what they're doing to the whole world πŸ“£ (well, to whoever's listening)

πŸ¦‹ DESCRIPTION πŸ¦‹

So here's the vibe: notifiers are supposed to create an s6-fifodir(7) in a hardcoded place in the filesystem, and then document where that spot is like the good citizen they are, no cap. Then listeners can subscribe to that s6-fifodir(7) and catch the events as they drop. πŸ”₯

check the s6/ftrigw.h header for the exact function prototypes β€” that's where the real receipts live, iykyk

πŸŽ€ Creating a fifodir

char const *path = "/var/lib/myservice/fifodir" ;
gid_t gid = -1 ;
int forceperms = 0 ;
int r = ftrigw_fifodir_make(path, gid, forceperms) ;

ftrigw_fifodir_make() creates an s6-fifodir(7) at the path location. ✨ And the return codes? Listen up:

  • it returns 0, and sets errno, if something goes wrong 😭
  • it returns 1 if it actually succeeds πŸŽ‰

Now for the spicy details:

  • if an s6-fifodir(7) owned by the user already exists at path, and forceperms is zero, then ftrigw_fifodir_make() immediately returns success. easy slay πŸ’…
  • if forceperms is nonzero, then it tries to adjust path's permissions before returning. lowkey doing a little extra credit 🧚

And about gid, bestie, this is important:

  • if gid is negative, then path gets created "public" β€” any listener at all will be able to subscribe to path. 🌈 open door policy
  • if gid is nonnegative, then path is created "private" β€” only processes belonging to group gid will be able to subscribe to path. πŸ”’ members only

πŸ’œ Sending an event

char event = 'a' ;
r = ftrigw_notify(path, event) ;

ftrigw_notify() sends event to all the processes that are currently subscribed to path. 🫢 It returns βˆ’1 if an error occurs, or the number of successfully notified processes. So like, the count of people who actually got the message β€” very main character of it tbh πŸ‘‘

🌸 Cleaning up

okay so this part is the "not me forgetting to clean my room" section πŸ™ˆ When stray KILL signals hit s6-ftrigrd(8) processes:

  1. it's a sign of incorrect system administration β€” yeah, that's a yikes πŸ’€
  2. they can leave unused named pipes in the s6-fifodir(7)

And it's the s6-fifodir(7)'s owner's job β€” i.e. the notifier's job, so literally you β€” to periodically do some housecleaning and remove those unused pipes. 🧹✨

r = ftrigw_clean(path) ;

ftrigw_clean() cleans path. Returns 0, and sets errno, if it encounters an error 😭 and it returns 1 if it succeeds πŸŽ‰ periodt.


⭐ SEE ALSO ⭐

This man page is ported from the authoritative documentation at: https://skarnet.org/software/s6/libs6/ftrigw.html πŸ¦‹

πŸ‘‘ AUTHORS πŸ‘‘

  • Laurent Bercot
  • Alexis <flexibeast@gmail.com> (man page port)

Debian πŸ’– September 29, 2021 πŸ’– that's the source, version and date bestie, mwah 🫢 go notify someone about it ✨

πŸ“¦ where this page comes from