Unbufferred file I/O
Scott "The Pseudo-Hacker" Neugroschl
abcscnge at csuna.UUCP
Fri May 20 13:58:41 AEST 1988
In article <2961 at crash.cts.com> cline at 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 <sys/types.h>
#include <sys/ioctl.h>
#include <termio.h>
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!!!
More information about the Comp.unix.xenix
mailing list