Unbuffered Stdio Input
Michael Meissner
meissner at osf.org
Wed Feb 21 03:31:04 AEST 1990
In article <378 at node17.mecazh.UUCP> paul at mecazh.UUCP (Paul Breslaw) writes:
| I have a little program that opens a master side pty and reads from it.
| I have another little program that opens the corresponding slave side
| and writes to it.
|
| If the master side is coded something like:-
|
| FILE *f;
| char buf[ BF ];
| int nr;
|
| f = fopen( master, "a+" );
| nr = fread( buf, sizeof( char ), BF, f );
|
| then the program hangs on the fread.
Fread will loop attempting to fill the entire buffer. If your records
are line oriented, I would recomend using fgets. If you need to get
the characters as soon as possible, I would recomend switching the pty
to CBREAK or RAW modes, and using getc() to read bytes as you need
them.
--
Michael Meissner email: meissner at osf.org phone: 617-621-8861
Open Software Foundation, 11 Cambridge Center, Cambridge, MA
Catproof is an oxymoron, Childproof is nearly so
More information about the Comp.lang.c
mailing list