TS_CLOSE_RESTRICTED(3)

✨ TS_CLOSE_RESTRICTED(3) ✨

okay so bestie, welcome to the tslib manual, section 3, and today's main character is ts_close_restricted πŸ’…


πŸŽ€ NAME πŸŽ€

ts_close_restricted β€” the way you drop in your own custom function for closing the touchscreen's input device file 🫢


🌸 SYNOPSIS 🌸

#include <tslib.h>

void (*ts_close_restricted)(int fd, void *user_data);

πŸ’– DESCRIPTION πŸ’–

so here's the vibe: ts_close_restricted() is useful if libts should not be run as root. like, imagine not wanting to hand root privileges to your touchscreen library β€” valid, honestly, iconic even πŸ‘‘

if you (the user) implement a function like that and assign it to the ts_close_restricted pointer, then ts_close() will call your function instead of hitting the close() system call directly. no cap. it's literally a little swap-in-and-slay situation πŸ”₯

and what should that function do? it should obviously close the device with file descriptor fd 🌈 meanwhile user_data is currently unused β€” so yeah, it's just kinda sitting there looking cute, not doing anything yet πŸ™ˆ

not me making you read a whole paragraph for "close the fd but make it custom" πŸ’€ but fr fr, every word of it matters.

πŸ¦‹ SEE ALSO πŸ¦‹


mwah, that's the whole page, bestie πŸ’œ this lil masterpiece lives in the tslib manual, section 3, and it signs off the same way it came in: TS_CLOSE_RESTRICTED(3) ✨ go forth and close your fds responsibly πŸŽ€