snp(4) tty snoop interface


In sys/snoop.h Ft int Fn ioctl fd SNPSTTY &dev Ft int Fn ioctl fd SNPGTTY &dev Ft int Fn ioctl fd FIONREAD &result


/dev/snp is a snoop device which allows users to attach to any tty and watch activities on it. The kernel must be compiled with device snp or the module must be loaded, for these devices to be available.

To associate a given device with a tty to be observed, open the device and a tty device, and then issue the SNPSTTY ioctl on device. The argument passed to the ioctl(2) is the address of a variable of type Vt int , holding the file descriptor of a tty device. To detach the device from a tty use a pointer to a value of -1.

The SNPGTTY ioctl returns information about the current tty attached to the open device.

The FIONREAD ioctl returns a positive value equal to the number of characters in a read buffer. Special values defined are:

device overflow occurred, device detached.
tty not attached.
device has been detached by user or tty device has been closed and detached.


The device first appeared in Fx 2.1 . In Fx 8.0 the driver was rewritten to work with the replaced TTY subsystem.


The author of the current implementation is An Ed Schouten Aq [email protected] . Previous versions of were based on code written by An Ugen J.S. Antsilevich Aq [email protected] .


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