exit locked 'getline' if pipe is closed
I am writing a program that reads from a pipe created with 'pipe'. The particular thread that reads the pipe does so with a 'getline' call and the other end of the pipe serves as the standard output for a forked process. When that process exits it closes the write end of the pipe, however if the thread is mid-getline it will freeze. Unlike std::cin the function will not exit with eof; it will lock presuming the pipe will be opened again. How do I get past this? I want it to lock as std::cin will but exit with eof as std::cin does when the other end is irrevocably closed. Thanks.
ta0kira |
The problem seems to be getting the forked process to exit; that's why the pipe locks in the thread. If I can figure out how to exit that process it should work. I think I need to just use an additional pthread instead of fork.
ta0kira |
All times are GMT -5. The time now is 01:45 AM. |