File:  [CSRG BSD Unix] / 40BSD / cmd / berknet / setmode.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 16:12:53 2018 UTC (8 years, 1 month ago) by root
Branches: MAIN, BSD
CVS tags: HEAD, BSD40
BSD 4.0

/* 
	setmode.c
	
	used to set the mode to cat files to check the net tty drivers
*/
# include <stdio.h>
# include <sgtty.h>
main(argc,argv)
  char **argv; {
	struct sgttyb stt;
	FILE *readtty;
	if(fork() != 0)exit(0);
	printf("kill %d\n",getpid());
	readtty = fopen(argv[1],"w");
	if(readtty == NULL)goto err1;
	if(gtty(fileno(readtty),&stt) < 0)goto err2;
	stt.sg_ispeed = stt.sg_ospeed = 9;  /* 1200 baud */
	stt.sg_erase = stt.sg_kill = 0;		/* erase and kill off */
	stt.sg_flags = ANYP;	/* even and odd parity, off everything else */
	if(stty(fileno(readtty),&stt) < 0)goto err3;
	sleep(30000);
err1:
	printf("Error1: ");
	perror(argv[1]);
	exit(1);
err2:
	printf("Error2: ");
	perror(argv[1]);
	exit(1);
err3:
	printf("Error3: ");
	perror(argv[1]);
	exit(1);
	}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.