LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   exit locked 'getline' if pipe is closed (https://www.linuxquestions.org/questions/programming-9/exit-locked-getline-if-pipe-is-closed-542515/)

ta0kira 04-01-2007 09:09 PM

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

ta0kira 04-02-2007 11:10 AM

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.