knowledge-database (beta)

Current group: comp.sources.d

Re: Opening the same file multiple times

Re: Opening the same file multiple times  
narvikdesi
From:narvikdesi
Subject:Re: Opening the same file multiple times
Date:17 Nov 2004 02:57:22 -0800
"Zahid Faizal" wrote in message news:<1100660769.941626.239990@z14g2000cwz.googlegroups.com>...
> Let us assume that an application opens the same file more than once
> (perhaps by mistake). I am assuming that only the first open() takes
> effect, and that the other open() calls are no-ops. Is that correct?
>
> Let us assume function A opens a file, and calls function B, which also
> opens the same file. Before returning, function B closes the file.
> After function B returns, function A makes a file I/O call for that
> file (not knowing that function B has already closed the file). I was
> expecting a failure, but on my system, it appears that the file I/O
> call happens in function A without any error. Am I missing something?
> Regards,
> Zahid

I think that function A opens filestream1, then calls function B,
which opens filestream2 and closes filestream2 upon returning. So
filestream1 is still open when function A resumes.
   

Copyright © 2006 knowledge-database   -   All rights reserved