"Paul Edwards" <kerravon@nosppaam.w3.towrites:
Quote:
"Richard Bos" <rlb@hoekstra-uitgeverij.nlwrote in message
news:4538ade9.244955277@news.xs4all.nl...
Quote:
>"Paul Edwards" <kerravon@nosppaam.w3.towrote:
>>
Quote:
Is it permissible in C89 to do an "fclose(stdout)"
and then exit, or is the C runtime library allowed to
assume that stdout remains open and thus unconditionally
do an fclose itself?
>>
>Yes, it's allowed. Whether it's wise is another matter, since in C89
>there is no portable way to get it back, and in C99 there is one way
>which is portable, but not guaranteed to work.
>
Thankyou. Now is the application program allowed to
call fclose(stdout) twice, and if so, what is the expected
return on the second close?
After a call to fclose(stdout), the value of stdout is indeterminate.
Calling fclose(stdout) a second time invokes undefined behavior.
If you call fclose(stdout) once, then it won't be closed again when
the program terminates. C99 7.20.4.3p4 says:
Next, all open streams with unwritten buffered data are flushed,
all open streams are closed, and all files created by the tmpfile
function are removed.
If stdout has been closed, then it isn't an open stream.
--
Keith Thompson (The_Other_Keith)
kst-u@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.