Temporarily close stdout?
- From: Joakim Hove <joakim.hove@xxxxxxxxx>
- Date: Wed, 30 Apr 2008 05:36:02 -0700 (PDT)
[ This question is about closing/reopening/... of stdout - I hope that
is on topic?]
Hello,
I have written a program in C; this programs uses an external
proprietary library. When calling a certain function in the external
library, the particular function writes a message to stdout. I am not
particularly interested in this message, and would like to silence it
- however I do not know how to do it. (I stdout and stderr my self, so
just redirecting into oblivion is not an option).
An excerpt of the code looks like this:
....
/* Offending call in external library. */
job_nr = lsb_submit( &request , &reply);
When this code is run - the offending function (or some function it
calls), writes
"Job <123456> is submitted to queue <common>"
An information I am completely uninterested in sending stdout. So I
wondered if it would be possible to do something like this:
....
/* Temporarily close stdout: */
fclose(stdout);
job_nr = lsb_submit( &request , &reply );
/* Reopen stdout */
stdout = fdopen(1 , "a");
I have tried the code listed above - but the fdopen() failed with "Bad
file descriptor" (I had not expected it to succeed ...). Anyway - any
suggestions would be highly appreciated.
Joakim
.
- Follow-Ups:
- Re: Temporarily close stdout?
- From: Richard Tobin
- Re: Temporarily close stdout?
- From: Willem
- Re: Temporarily close stdout?
- Prev by Date: Re: Is cast operator unary or binary? How many operands?
- Next by Date: Re: Is cast operator unary or binary? How many operands?
- Previous by thread: free fiction
- Next by thread: Re: Temporarily close stdout?
- Index(es):
Relevant Pages
|