开发者

Read from unix pipe when there's no one to write to it. (C++)

开发者 https://www.devze.com 2022-12-31 08:32 出处:网络
If I spawn a child and pass him a pipe, the child writes to the output of the pipe(to the parent) and after that the chil开发者_运维百科d dies. Can the parent read from the pipe what the child had wri

If I spawn a child and pass him a pipe, the child writes to the output of the pipe(to the parent) and after that the chil开发者_运维百科d dies. Can the parent read from the pipe what the child had written before it died? Thanks. (ps: I'm talking about C++)


Yes, but watch for the buffer space: if the parent is not yet reading, the child will not be able to write more than the buffer size, which is different from system to system, 16k on mine.

0

精彩评论

暂无评论...
验证码 换一张
取 消