LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-01-2007, 09:09 PM   #1
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
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
 
Old 04-02-2007, 11:10 AM   #2
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Original Poster
Rep: Reputation: Disabled
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
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Error in getline harrylee2003 Programming 8 08-04-2006 04:46 PM
Problem with sftp! (debug1: Exit status 127 Connection closed) nena Linux - Security 1 01-26-2006 07:29 PM
how to use fork/pipe to decrement a global varialbe Y and exit when Y is 0 keiwu Programming 1 02-19-2005 11:33 PM
getline hylke Programming 9 06-03-2004 01:24 PM
g++ and cin.getline() codeviking Programming 8 07-03-2003 07:42 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:24 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration