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?
|
from the terminal, control-D
|
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 |
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. |