Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!ames!pasteur!ucbvax!decwrl!hplabs!sdcrdcf!csun!csuna!abcscnge From: abcscnge@csuna.UUCP (Scott "The Pseudo-Hacker" Neugroschl) Newsgroups: comp.unix.xenix Subject: Re: Unbufferred file I/O Message-ID: <1220@csuna.UUCP> Date: 20 May 88 03:58:41 GMT References: <2961@crash.cts.com> Reply-To: abcscnge@csuna.UUCP (Scott "The Pseudo Hacker" Neugroschl) Organization: California State University, Northridge Lines: 46 In article <2961@crash.cts.com> cline@pnet01.cts.com (Ben Humphreys) writes: [ stuff about how write is buffered, and wants to go unbuffered input ] Use ioctl(). Set the terminal flags to: #include #include #include struct termio ttyold, ttynew; /* get the terminal params twice */ if (ioctl(0,TCGETA,&ttyold) == -1 || ioctl(0,TCGETA,&ttynew) == -1) { perror("program"); exit(-1); } /* set up for unbuffered I/O */ ttynew.c_cc[VMIN] = 1; ttynew.c_cc[VTIME] = 0; ttynew.c_lflags &= ~ICANON; if (ioctl(0,TCSETAW,&ttynew) == -1) { perror("program"); exit(-1); } /* Stuff to talk to other user here */ /* clean up when done */ ioctl(0,TCSETAW,&ttyold); exit(0); /* done */ Note that you should catch SIGINT and probably SIGQUIT too, so that you can clean up gracefully before dropping dead. -- Scott "The Pseudo-Hacker" Neugroschl UUCP: ...!ihnp4!csun!csuna!abcscnge -- "They also surf who stand on waves" -- Disclaimers? We don't need no stinking disclaimers!!!