Is close/fclose on stdin guaranteed to be correct?

后端 未结 3 654
难免孤独
难免孤独 2020-12-06 02:59

It seems as though the following calls do what you\'d expect (close the stream and not allow any further input - anything waiting for input on the stream returns error), but

3条回答
  •  鱼传尺愫
    2020-12-06 03:16

    DO NOT DO a close on fileno(FILE*). FILE is a buffering object. Looking into its implementation and meddling with its state carries all the caveats and dangers that would come with similar misbehavior on any other software module.

    Don't do it.

    AGH. Seriously. Nasty.

提交回复
热议问题