SNP(4)

🌸 NAME 🌸

okay bestie, welcome to the manual page for snp β€” the tty snoop interface πŸ’… (and yes, this is from the Kernel Interfaces Manual, section 4, so you know it's the real deal ✨)


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <sys/snoop.h>

int
ioctl(fd, SNPSTTY, &dev);

int
ioctl(fd, SNPGTTY, &dev);

int
ioctl(fd, FIONREAD, &result);

✨ DESCRIPTION ✨

/dev/snp is a snoop device, and its whole vibe is: you attach it to any tty and just... watch. πŸ‘€ Watch all the activity happening on it. But β€” and this is important β€” the kernel has to be compiled with device snp, OR the snp module has to be loaded, for these devices to even exist. no module, no snooping, fr fr 😭

So here's how you get it set up, step by step 🫢

  1. Open the snp device.
  2. Open the tty device you wanna observe.
  3. Issue the SNPSTTY ioctl on the snp device.

The argument you pass to ioctl(2) is the address of a variable of type int, and that variable holds the file descriptor of a tty device. πŸŽ€

Wanna detach the snp device from a tty? Pass a pointer to a value of -1. That's it. goodbye πŸ‘‹

The SNPGTTY ioctl gives you info about the current tty attached to the open snp device. like, "who am I currently stalking rn" energy πŸ•΅οΈβ™€οΈ

The FIONREAD ioctl returns a positive value equal to the number of characters in a read buffer. and there are some special values defined, so let's get into them πŸ‘‘

  • SNP_OFLOW β€” device overflow occurred, device detached. πŸ’€
  • SNP_TTYCLOSE β€” tty not attached. πŸ™ˆ
  • SNP_DETACH β€” snp device has been detached by user, OR the tty device has been closed and detached. 😭

πŸ”₯ SEE ALSO πŸ”₯

go read those too, bestie, they're the friend group 🌈


πŸŽ€ HISTORY πŸŽ€

The snp device first appeared in FreeBSD 2.1. πŸ“œ Then in FreeBSD 8.0 the snp driver was rewritten to work with the replaced TTY subsystem. glow-up era, honestly ✨


πŸ‘‘ AUTHORS πŸ‘‘

The author of the current implementation is Ed Schouten <ed@FreeBSD.org>. πŸ’–

Previous versions of snp were based on code written by Ugen J.S. Antsilevich <ugen@NetVision.net.il>. 🫢


πŸ’€ BUGS πŸ’€

This version of snp does not return proper error codes when calling FIONREAD. It also does not allow SNPSTTY to detach itself from the TTY.

so yeah. it's giving "we know, we know" 😭 not me warning you about it though β€” that's literally what the manpage says, no cap.


and that's the whole page, babes 🧚 from the Debian folks, dated November 5, 2008, filed under SNP(4) β€” mwah πŸ’…βœ¨

πŸ“¦ where this page comes from