LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Send EOF to stdin? (C) (https://www.linuxquestions.org/questions/programming-9/send-eof-to-stdin-c-421858/)

smoothdogg00 03-05-2006 10:13 AM

Send EOF to stdin? (C)
 
When something is reading from stdin, such as the "od" program, how do I send it an "EOF" signal, or something to stop the reading?

aluser 03-05-2006 10:48 AM

from the terminal, control-D

ta0kira 03-06-2006 06:05 PM

Depends. Which stdin operation are you trying to EOF? If stdin is console input, do what aluser said. If the ONLY thing you want to send is EOF, use 'echo -n | (your program)'. If you are sending it FROM your C program, you are pretty much stuck with exiting from the program, at which point the state of its stdout will be EOF, which will in turn be reflected in whichever stdin it was redirected to. I'm pretty sure you can't just send EOF from within C without getting a hold of an underlying buffer, which aren't standardized, and therefore would leave you with some dirty programming to do.
ta0kira

primo 03-07-2006 07:10 PM

Maybe you can play with /proc/<pid>/fd/0

Try deleting the file
Try reading it completely
Try truncating it.


All times are GMT -5. The time now is 03:12 PM.