How to buffer stdout in memory and write it from a dedicated thread

后端 未结 7 470
既然无缘
既然无缘 2020-11-29 03:18

I have a C application with many worker threads. It is essential that these do not block so where the worker threads need to write to a file on disk, I have them write to a

7条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-29 03:29

    Why don't you wrap your entire application in another? Basically, what you want is a smart cat that copies stdin to stdout, buffering as necessary. Then use standard stdin/stdout redirection. This can be done without modifying your current application at all.

    ~MSalters/# YourCurrentApp | bufcat
    

提交回复
热议问题