Unbuffered Stdio Input

Paul Breslaw paul at mecazh.UUCP
Tue Feb 20 09:29:29 AEST 1990


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.

If, however, I replace the last line with

    nr = read( fileno( f ), buf, BF );

then the read succeeds. An optional 

    setbuf( f, NULL );

does not alter the situation.

I have tested the program on an HP9000/340 (HP-UX 6.5) and a 
Sun3/50 (SunOS 3.5) with not quite identical non-events :-)

Any suggestions what I've done wrong?


Paul Breslaw




-- 
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Paul Breslaw, Mecasoft SA,          |  telephone :  41 1 362 2040
Guggachstrasse 10, CH-8057 Zurich,  |  e-mail    :  mcsun!chx400!mecazh!paul
Switzerland.                        |               paul at mecazh.UUCP



More information about the Comp.lang.c mailing list