unopenable tty

Andrew Myles expc55 at castle.ed.ac.uk
Thu Sep 20 23:55:15 AEST 1990


Try (assuming file descriptor 1 is still your tty and not a pipe, else
open the tty yourself for any operation e.g. read or write)..

#include <sys/ioctl.h>		/* or whatever your machine needs */

int main()
{
ioctl(1,TIOCEXCL);		/* no more opens - when I use this I find
				   that mail demons cannot tell me of new
				   mail, sysops cannot wall etc... :-) */

/* insert your code here. Any other processes attempting to do
   things like open(this tty,O_RDONLY); will fail now even if
   this tty is crwxrwxrwx... */

ioctl(1,TIOCNXCL);		/* Free device on fildes 1. You didn't
				   do close(1) did you ?  If so, now
				   you can't re-open it either - so do
				   NOT do it to other peoples tty unless
				   they know how to free it.*/
return (0);
}

 Hope this works for you. Andrew.



More information about the Comp.unix.questions mailing list