473,387 Members | 1,540 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

fopen(log_file, "a");

Has anyone run into documentation that describes how fopen(log_file,
"a") behaves when it is potentialy used (called/referenced) 1000's of
times an hour on a single resource file? I am trying to find out the
adverse effects of fopen(log_file, "a") potetialy being called at the
same time and trying to open the same file. Is the file locked when
fopen(log_file, "a") is used?

I would appreciate any information that anyone might have,

Cheers
Nov 14 '05 #1
5 5348

"Arturo Ordaz" <el*****@hotmail.com> wrote in message
news:7e*************************@posting.google.co m...
Has anyone run into documentation that describes how fopen(log_file,
"a") behaves when it is potentialy used (called/referenced) 1000's of
times an hour on a single resource file? I am trying to find out the
adverse effects of fopen(log_file, "a") potetialy being called at the
same time and trying to open the same file. Is the file locked when
fopen(log_file, "a") is used?


The following is from the man page of fopen ( on Solaris 9 )
------------------------------------------------------
Opening a file with append mode (a as the first character in
the mode argument) causes all subsequent writes to the file
to be forced to the then current end-of-file, regardless of
intervening calls to fseek(3C). If two separate processes
open the same file for append, each process may write freely
to the file without fear of destroying output being written
by the other. The output from the two processes will be
intermixed in the file in the order in which it is written.

-------------------------------------------

Vu
Nov 14 '05 #2
Vu Pham wrote:
"Arturo Ordaz" <el*****@hotmail.com> wrote in message
news:7e*************************@posting.google.co m...
Has anyone run into documentation that describes how fopen(log_file,
"a") behaves when it is potentialy used (called/referenced) 1000's of
times an hour on a single resource file? I am trying to find out the
adverse effects of fopen(log_file, "a") potetialy being called at the
same time and trying to open the same file. Is the file locked when
fopen(log_file, "a") is used?

The following is from the man page of fopen ( on Solaris 9 )
------------------------------------------------------
Opening a file with append mode (a as the first character in
the mode argument) causes all subsequent writes to the file
to be forced to the then current end-of-file, regardless of
intervening calls to fseek(3C). If two separate processes
open the same file for append, each process may write freely
to the file without fear of destroying output being written
by the other. The output from the two processes will be
intermixed in the file in the order in which it is written.


OK, but that's hardly relevant to *standard* C (the only topic here),
where multiple processes are not defined. It's only relevant to Solaris
9, which may not be what the OP is using.

The standard answer is that the C definition assumes there is only a
single thread of execution, so it never defines what happens when two
things happen "at the same time". You have to consult your
implementation's documentation, and what it says is off-topic here.

-Kevin
--
My email address is valid, but changes periodically.
To contact me please use the address from a recent posting.
Nov 14 '05 #3
el*****@hotmail.com (Arturo Ordaz) wrote:
# Has anyone run into documentation that describes how fopen(log_file,
# "a") behaves when it is potentialy used (called/referenced) 1000's of
# times an hour on a single resource file? I am trying to find out the
# adverse effects of fopen(log_file, "a") potetialy being called at the

Operating system specific. Some might keep enough of the file system in
memory that there's little overhead. Others might have to crank out the
disk arm everytime.

# same time and trying to open the same file. Is the file locked when
# fopen(log_file, "a") is used?

Unless your operating system says opens are exclusive, you should take
responsibility for serialisation.

--
Derk Gwen http://derkgwen.250free.com/html/index.html
You hate people.
But I love gatherings. Isn't it ironic.
Nov 14 '05 #4
Kevin Goodsell <us*********************@neverbox.com> wrote in message news:<Z2*****************@newsread1.news.pas.earth link.net>...
Vu Pham wrote:
"Arturo Ordaz" <el*****@hotmail.com> wrote in message
news:7e*************************@posting.google.co m...
Has anyone run into documentation that describes how fopen(log_file,
"a") behaves when it is potentialy used (called/referenced) 1000's of
times an hour on a single resource file? I am trying to find out the
adverse effects of fopen(log_file, "a") potetialy being called at the
same time and trying to open the same file. Is the file locked when
fopen(log_file, "a") is used?

The following is from the man page of fopen ( on Solaris 9 )
------------------------------------------------------
Opening a file with append mode (a as the first character in
the mode argument) causes all subsequent writes to the file
to be forced to the then current end-of-file, regardless of
intervening calls to fseek(3C). If two separate processes
open the same file for append, each process may write freely
to the file without fear of destroying output being written
by the other. The output from the two processes will be
intermixed in the file in the order in which it is written.


OK, but that's hardly relevant to *standard* C (the only topic here),
where multiple processes are not defined. It's only relevant to Solaris
9, which may not be what the OP is using.

The standard answer is that the C definition assumes there is only a
single thread of execution, so it never defines what happens when two
things happen "at the same time". You have to consult your
implementation's documentation, and what it says is off-topic here.


The standard provides other assurances as far as reading back
information which was written. This would seem to make the above
quoted implementation potentially broken (if it claims conformance).

--
Peter
Nov 14 '05 #5
On 12 Jan 2004 15:34:39 -0800, ai***@acay.com.au (Peter Nilsson) wrote
in comp.lang.c:
Kevin Goodsell <us*********************@neverbox.com> wrote in message news:<Z2*****************@newsread1.news.pas.earth link.net>...
Vu Pham wrote:
"Arturo Ordaz" <el*****@hotmail.com> wrote in message
news:7e*************************@posting.google.co m...

>Has anyone run into documentation that describes how fopen(log_file,
>"a") behaves when it is potentialy used (called/referenced) 1000's of
>times an hour on a single resource file? I am trying to find out the
>adverse effects of fopen(log_file, "a") potetialy being called at the
>same time and trying to open the same file. Is the file locked when
>fopen(log_file, "a") is used?
The following is from the man page of fopen ( on Solaris 9 )
------------------------------------------------------
Opening a file with append mode (a as the first character in
the mode argument) causes all subsequent writes to the file
to be forced to the then current end-of-file, regardless of
intervening calls to fseek(3C). If two separate processes
open the same file for append, each process may write freely
to the file without fear of destroying output being written
by the other. The output from the two processes will be
intermixed in the file in the order in which it is written.


OK, but that's hardly relevant to *standard* C (the only topic here),
where multiple processes are not defined. It's only relevant to Solaris
9, which may not be what the OP is using.

The standard answer is that the C definition assumes there is only a
single thread of execution, so it never defines what happens when two
things happen "at the same time". You have to consult your
implementation's documentation, and what it says is off-topic here.


The standard provides other assurances as far as reading back
information which was written. This would seem to make the above
quoted implementation potentially broken (if it claims conformance).


Indeed the standard does, but nowhere does it specify that such a
guarantee is true if anything other than the individual executable
modifies the file. And that includes another instance running
concurrently, which is something not defined at all by the C standard.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Nov 14 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: lkrubner | last post by:
I want to give users the power to edit files from an easy interface, so I create a form and a PHP script called "fileUpdate". It does a reasonable about of error checking and prints out some...
10
by: Dave O'Hearn | last post by:
I want to open a file for both reading and writing, but when I do "ios::in|ios::out" with an fstream, it creates the file if it doesn't already exist. I don't like that last part. C's fopen has the...
1
by: clusardi2k | last post by:
Hello, I have a shared drive on SGI, Linux, and Windows. The fact that I'm using a shared drive may be mute information. The problem is within the same program a second call to fopen does not...
145
by: Sidney Cadot | last post by:
Hi all, In a discussion with Tak-Shing Chan the question came up whether the as-if rule can cover I/O functions. Basically, he maintains it can, and I think it doesn't. Consider two...
7
by: clusardi2k | last post by:
Hello, I have a shared drive on SGI, Linux, and Windows. A second call to fopen doesn't create the file if it has been deleted. I would like to use fopen for its pointer return value to...
8
by: VijaKhara | last post by:
Hi all, Please tell me how to create a file (using fopen) in a sub-folder (such as sub-folder "Mygoal")? I tried if ( ( fp = fopen ( "mygoal\myfile.tif", "wb" ) ) == NULL ) { fprintf (...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.