stdio(fdopen)

utzoo!decvax!ucbvax!unix-wizards utzoo!decvax!ucbvax!unix-wizards
Fri Oct 23 19:45:18 AEST 1981


>From dsp.dove at MIT-SPEECH@MIT-AI Fri Oct 23 17:06:30 1981
I just tripped over a "feature" of the stdio package.  I was setting up a cu.c
with buffering and trying to get it to recover after an interrupt while it
was sending a file.  It turns out that once IOERR is set in the _iob
associated with the stream it must be closed to clear the error and allow
further output (yuk).  It had been opened by using fdopen on a previously
opened fd for output, so I had it call fclose and fdopen again.  Well, that
didn't work because fdopen just associates the stream with the fd without
dup'ing the fd, so the close closed the fd and the subsequent fdopen referred
to a now invalid fd (which it didn't test for validity)!  Wonderful!!!
-------



More information about the Comp.unix.wizards mailing list