Re: Temporarily close stdout?



Thank you for answering.

[I have looked at the dup/dup2 calls, I agree that these seem to be
useful for me, but those man-pages are just above my limit I am
afraid.]

It looks as if you're using something Posix-like.  

That is right.

But closing stdout is dubious in the first place.  Are you sure the
library won't complain about stdout being closed?

Yes - I was also uncomfortable with that. I had no strong will to
close() stdout, it was merely a suggestion on my behalf.

It would be better to freopen() stdout to /dev/null.

I have tried:

....
/* Temporarily redirect stdout -> /dev/null */
stdout = freopen("/dev/null" , "w" , stdout);

/* Offending call */
lsb_submit( &request , &reply );

/* restore stdout */
stdout = freopen("/dev/stdout" , "w" , stdout);

But - the last freopen() fails with 2:No such file or directory.

Suggestions?

Joakim
.



Relevant Pages

  • Re: MP2 audio files
    ... After replacing Walt Davidson with a small shell script on Thursday 05 ... the following appeared on stdout: ... > The suggestion of loading it into Windows Media Player, ...
    (uk.radio.amateur)
  • Re: Ceramic Filters..
    ... After replacing Nic Percival with a small shell script on Wednesday 30 Nov ... the following appeared on stdout: ... > Hard to find, any suggestion most welcome. ... laden sleigh and nine reindeeer, Santa, you swine. ...
    (uk.radio.amateur)
  • Question about freopen() failure
    ... What happens to the existing file stream if freopenfails? ... If the specified filename fails to open, ... Am I correct that an freopenon stdout that fails leaves the program ... platform at least, this does occur.) ...
    (comp.lang.c)
  • Re: Calling the native Linux mutt module from Java...
    ... > Read from the child process' stdout and stderr streams, ... > probably tells you why it fails. ...
    (comp.lang.java.programmer)
  • Re: Gareth Withdrawel symptoms
    ... the following appeared on stdout: ... Moi? ...   I'm wounded by that suggestion. ...
    (uk.radio.amateur)