LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 03-05-2006, 10:13 AM   #1
smoothdogg00
Member
 
Registered: Feb 2006
Location: Maine
Distribution: Ubuntu
Posts: 44

Rep: Reputation: 15
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?
 
Old 03-05-2006, 10:48 AM   #2
aluser
Member
 
Registered: Mar 2004
Location: Massachusetts
Distribution: Debian
Posts: 557

Rep: Reputation: 43
from the terminal, control-D
 
Old 03-06-2006, 06:05 PM   #3
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
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
 
Old 03-07-2006, 07:10 PM   #4
primo
Member
 
Registered: Jun 2005
Posts: 542

Rep: Reputation: 34
Maybe you can play with /proc/<pid>/fd/0

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


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
EOF and \n exvor Programming 4 12-27-2005 02:20 PM
EOF finding Goblin_C_Noob Programming 7 09-10-2005 09:58 AM
finding the eof nodger Programming 12 11-26-2004 02:17 AM
eof ... c ... linux xviddivxoggmp3 Programming 6 03-31-2004 12:56 PM
<< Eof ? sikandar Linux - Software 5 09-18-2003 11:39 AM

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

All times are GMT -5. The time now is 08:58 AM.

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