Determine the size of a pipe without calling read()

后端 未结 13 953
无人共我
无人共我 2020-12-19 03:56

I need a function called SizeOfPipe() which should return the size of a pipe - I only want to know how much data is in the pipe and not actually read data off t

13条回答
  •  盖世英雄少女心
    2020-12-19 04:38

    There is no generic, portable way to tell how much data is available in a pipe without reading it. At least not under POSIX specifications.

    Pipes are not seekable, and neither is it possible to put the data back into the reading end of a pipe.

    Platform-specific tricks might be possible, though. If your question is platform-specific, editing your question to say so might improve your chances to get a working answer.

提交回复
热议问题