1*a73efc9aScomay static char sccsid[] = "@(#)setmode.c 4.1 (Berkeley) 10/02/82"; 2*a73efc9aScomay 3*a73efc9aScomay /* 4*a73efc9aScomay setmode.c 5*a73efc9aScomay 6*a73efc9aScomay used to set the mode to cat files to check the net tty drivers 7*a73efc9aScomay */ 8*a73efc9aScomay # include <stdio.h> 9*a73efc9aScomay # include <sgtty.h> main(argc,argv)10*a73efc9aScomaymain(argc,argv) 11*a73efc9aScomay char **argv; { 12*a73efc9aScomay struct sgttyb stt; 13*a73efc9aScomay FILE *readtty; 14*a73efc9aScomay if(fork() != 0)exit(0); 15*a73efc9aScomay printf("kill %d\n",getpid()); 16*a73efc9aScomay readtty = fopen(argv[1],"w"); 17*a73efc9aScomay if(readtty == NULL)goto err1; 18*a73efc9aScomay if(gtty(fileno(readtty),&stt) < 0)goto err2; 19*a73efc9aScomay stt.sg_ispeed = stt.sg_ospeed = 9; /* 1200 baud */ 20*a73efc9aScomay stt.sg_erase = stt.sg_kill = 0; /* erase and kill off */ 21*a73efc9aScomay stt.sg_flags = ANYP; /* even and odd parity, off everything else */ 22*a73efc9aScomay if(stty(fileno(readtty),&stt) < 0)goto err3; 23*a73efc9aScomay sleep(30000); 24*a73efc9aScomay err1: 25*a73efc9aScomay printf("Error1: "); 26*a73efc9aScomay perror(argv[1]); 27*a73efc9aScomay exit(1); 28*a73efc9aScomay err2: 29*a73efc9aScomay printf("Error2: "); 30*a73efc9aScomay perror(argv[1]); 31*a73efc9aScomay exit(1); 32*a73efc9aScomay err3: 33*a73efc9aScomay printf("Error3: "); 34*a73efc9aScomay perror(argv[1]); 35*a73efc9aScomay exit(1); 36*a73efc9aScomay } 37