Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | James Kuyper <jameskuyper@verizon.net> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: open stdin a second time |
| Date | 2011-11-11 15:31 -0500 |
| Organization | A noiseless patient Spider |
| Message-ID | <4EBD8615.2040607@verizon.net> (permalink) |
| References | <j9jvia$gsb$1@speranza.aioe.org> |
On 11/11/2011 03:11 PM, FBert wrote:
> Hi,
>
> I´m opening stdin to get a file and pass it through a pipe.
>
> razor=popen("/var/qmail/bin/razor-check -home=/var/qmail/razor",
> "w");
> while((ret=fread(linha,1,sizeof(linha),stdin))>0)
> {fwrite(linha,1,sizeof(linha),razor);}
> pclose(razor);
>
> After that, if razor returns me an error I want to send an email with
> the original message attached...but how can I re-read stdin to do
> that.
>
> I do not want to save the message to a temp file or save it to memory
> for i/o questions. Is there a way to re-read stdin ?
That depends upon what kind stream stdin is. The message has to be
stored somewhere if you're to retrieve it. If stdin is a terminal, for
instance, if you don't save the message yourself, then it isn't saved
anywhere, and you're out of luck.
On the other hand, if stdin is a file, the information is saved - in
that file. You can use rewind() to go back to the beginning of the file,
or either fseek() or fsetpos() to go back to specific saved positions in
the file.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
open stdin a second time FBert <anon@devnull.invalid> - 2011-11-11 20:11 +0000 Re: open stdin a second time James Kuyper <jameskuyper@verizon.net> - 2011-11-11 15:31 -0500 Re: open stdin a second time Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-11-11 20:12 -0500
csiph-web