Date: Sat, 17 Feb 2001 20:31:43 +0200 From: "Eli Zaretskii" Sender: halo1 AT zahav DOT net DOT il To: "Mark E." Message-Id: <7704-Sat17Feb2001203141+0200-eliz@is.elta.co.il> X-Mailer: Emacs 20.6 (via feedmail 8.3.emacs20_6 I) and Blat ver 1.8.6 CC: djgpp-workers AT delorie DOT com In-reply-to: <3A8D7266.19805.561972@localhost> (snowball3@bigfoot.com) Subject: Re: O_TEMPORARY References: <3A8C7B40 DOT 5144 DOT 6753FD AT localhost> (snowball3 AT bigfoot DOT com) <3A8D7266 DOT 19805 DOT 561972 AT localhost> Reply-To: djgpp-workers AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp-workers AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk > From: "Mark E." > Date: Fri, 16 Feb 2001 18:33:10 -0500 > > The only flaw I see is if > the file is opened first without O_TEMPORARY, the second open with > O_TEMPORARY won't be able to find out about the first one. > > Ideas on what to do here and why are definitely welcome. After spending some time thinking about this and playing with several ideas, I came to a conclusion that the simplest way is the best. That is, simply record each open file in the per-handle array that you invented for the O_TEMPORARY feature, even if it is not open with O_TEMPORARY. You will have to flag the ``normal'' (non-temporary) handles in some way, so that a call to _close won't remove them unless the same file is later open with O_TEMPORARY. When a file is open with O_TEMPORARY, search for the same file name in the array of recorded handles, and if you find the name, treat it as a call to `dup'. Another issue related to this is what about the files that are opened with O_TEMPORARY, but not explicitly closed before the program exits. I guess we will need to make an exit hook along the lines of the hook in stdiohk.c, which is called by the exit code.