HP C - dup2(file_desc1,file_desc2) question: implicit CLOSE?
- From: "Uli Bellgardt" <uli_bellgardt@xxxxxxxxxxx>
- Date: 10 Jan 2006 01:38:01 -0800
Hello,
I am using dup2 (file_desc, fileno(stdout)) to redirect a program's
output to a file. After some time, or after some amount of output has
been written (whatever comes first), the program opens a new output
file, and repeats above dup2 (...) statement to route the output to a
new file. The redirection works fine, all output appears in the correct
files just as expected.
But: After a while, the program is left with an increasing number of
open output files. The reason for this is clearly that I did not CLOSE
the output files, and the fix is trivial.
The C documentation states "If file_desc2 is connected to an open file,
that file is closed".
>>From this, I would expect that an previous output file is closed
implicitely with the next dup2(...), and so on. My program obviously
does not behave like this. Am I wrong with this expectation?
Compaq C++ V6.5-046 for OpenVMS Alpha V8.2
Kind regards,
-Uli
.
- Prev by Date: Re: Suggestion for INSTALL PURGE and SHUTDOWN.COM
- Next by Date: HP C - dup2(file_desc1,file_desc2) question: implicit CLOSE?
- Previous by thread: How to prevent users from telnet-login ?
- Next by thread: HP C - dup2(file_desc1,file_desc2) question: implicit CLOSE?
- Index(es):
Relevant Pages
|