Is fopen blocked?

B

Bo Yang

Hi guys,
I suddenly think about this question. While we use fopen() to open a
file and then do reading and writing. Is fopen a blocked function?

Regards!
Bo
 
I

Ian Collins

Bo said:
Hi guys,
I suddenly think about this question. While we use fopen() to open a
file and then do reading and writing. Is fopen a blocked function?
What is a blocked function?
 
B

Bo Yang

Ian Collins :
What is a blocked function?
I mean if there is soem other process is now using the file, how the
fopen will act? It fails directly or just waiting there to the process
which uses the file release the file?

Regards!
Bo
 
I

Ian Collins

Bo said:
Ian Collins :
I mean if there is soem other process is now using the file, how the
fopen will act? It fails directly or just waiting there to the process
which uses the file release the file?
The standard doesn't say, why should there be a problem with more than
one process opening a file?

There may be platform dependent error returns if a file is exclusive.
 
B

Bo Yang

Ian Collins :
The standard doesn't say, why should there be a problem with more than
one process opening a file?

There may be platform dependent error returns if a file is exclusive.
So, if there are many process want to do fopen("file","a"); . Are they
all success? Or there are some will failed?
 
I

Ian Collins

Bo said:
Ian Collins :
So, if there are many process want to do fopen("file","a"); . Are they
all success? Or there are some will failed?

That depends on the platform and system specific things like file locks.
 
M

Mark McIntyre

Ian Collins :
So, if there are many process want to do fopen("file","a"); . Are they
all success? Or there are some will failed?

As Ian said, the standard doesn't say - it depends on your operating
system and hardware. You will need to read the documentation for your
specific platform (or ask in a newsgroup dedicated to your platform)
to find out how it behaves.
--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
 
D

Default User

Bo Yang wrote:

I mean if there is soem other process is now using the file, how the
fopen will act? It fails directly or just waiting there to the
process which uses the file release the file?

As stated by the others, the Standard doesn't specify. Generally, they
will all be able to open. That's why most platforms provide some sort
of file-locking ability.




Brian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

fopen 20
fopen question 7
fopen 17
HELP:function at c returning (null) 4
PHP failed to create file 13
Working with files 1
Problem with fopen 13
URGENT 1

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top