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
|