1.\" 2.Dd September 24, 2022 3.Dt SNP 4 4.Os 5.Sh NAME 6.Nm snp 7.Nd tty snoop interface 8.Sh SYNOPSIS 9.In sys/snoop.h 10.Ft int 11.Fn ioctl fd SNPSTTY &dev 12.Ft int 13.Fn ioctl fd SNPGTTY &dev 14.Ft int 15.Fn ioctl fd FIONREAD &result 16.Sh DESCRIPTION 17.Pa /dev/snp 18is a snoop device which allows users to attach to any tty 19and watch activities on it. 20The kernel must be compiled with 21.Cd "device snp" , 22or the 23.Nm 24module must be loaded, 25for these devices to be available. 26.Pp 27To associate a given 28.Nm 29device with a tty to be observed, open the 30.Nm 31device and a tty device, and then issue the 32.Dv SNPSTTY 33ioctl on 34.Nm 35device. 36The argument passed to the 37.Xr ioctl 2 38is the address of a variable of type 39.Vt int , 40holding the file descriptor of a tty device. 41To detach the 42.Nm 43device from a tty use a pointer to a value of 44\-1. 45.Pp 46The 47.Dv SNPGTTY 48ioctl returns information about the current tty attached to 49the open 50.Nm 51device. 52.Pp 53The 54.Dv FIONREAD 55ioctl returns a positive value equal to the number of characters 56in a read buffer. 57Special values defined are: 58.Bl -tag -width ".Dv SNP_TTYCLOSE" 59.It Dv SNP_TTYCLOSE 60tty not attached. 61.It Dv SNP_DETACH 62.Nm 63device has been detached by user or tty device has been closed 64and detached. 65.El 66.Sh SEE ALSO 67.Xr pty 4 , 68.Xr kldload 8 , 69.Xr watch 8 70.Sh HISTORY 71The 72.Nm 73device first appeared in 74.Fx 2.1 . 75In 76.Fx 8.0 77the 78.Nm 79driver was rewritten to work with the replaced TTY subsystem. 80.Sh AUTHORS 81.An -nosplit 82The author of the current implementation is 83.An \&Ed Schouten Aq Mt ed@FreeBSD.org . 84Previous versions of 85.Nm 86were based on code written by 87.An Ugen J.S. Antsilevich Aq Mt ugen@NetVision.net.il . 88