comp.lang.c
[Top] [All Lists]

Re: Temporarily close stdout?

Subject: Re: Temporarily close stdout?
From: Willem
Date: Wed, 30 Apr 2008 12:41:24 +0000 UTC
Newsgroups: comp.lang.c

Joakim wrote:
) [ 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).
)    ....
)    /* 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.

Given that you're using fdopen(), the dup() function is probably
available to you, and I think it could be of use.


SaSW, Willem
-- 
Disclaimer: I am in no way responsible for any of the statements
            made in the above text. For all I know I might be
            drugged or something..
            No I'm not paranoid. You all think I'm paranoid, don't you !
#EOT

<Prev in Thread] Current Thread [Next in Thread>
Privacy Policy