knowledge-database (beta)

Current group: comp.sources.d

Re: Opening the same file multiple times

Re: Opening the same file multiple times  
Tim Haynes
From:Tim Haynes
Subject:Re: Opening the same file multiple times
Date:Wed, 17 Nov 2004 10:31:11 +0000
"Zahid Faizal" writes:

> 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?

No. RTBM open(2).

#include
#include
#include
#include

int main(void)
{
int fd1, fd2;
fd1=open("/tmp/pants", O_CREAT);
printf("FD1 is %d\n", fd1);
fd2=open("/tmp/pants", O_CREAT);
printf("FD2 is %d\n", fd2);
close(fd2);
close(fd1);

return 0;
}

~Tim
--
10:30:24 up 91 days, 19:09, 0 users, load average: 0.03, 0.05, 0.00
piglet@stirfried.vegetable.org.uk |There's peat smoke rising
http://spodzone.org.uk/cesspit/ |From the village chimneys
   

Copyright © 2006 knowledge-database   -   All rights reserved