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