473,991 Members | 2,294 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 5382

"Arturo Ordaz" <el*****@hotmai l.com> wrote in message
news:7e******** *************** **@posting.goog le.com...
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*****@hotmai l.com> wrote in message
news:7e******** *************** **@posting.goog le.com...
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_fil e, "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************ *********@never box.com> wrote in message news:<Z2******* **********@news read1.news.pas. earthlink.net>. ..
Vu Pham wrote:
"Arturo Ordaz" <el*****@hotmai l.com> wrote in message
news:7e******** *************** **@posting.goog le.com...
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_fil e, "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************ *********@never box.com> wrote in message news:<Z2******* **********@news read1.news.pas. earthlink.net>. ..
Vu Pham wrote:
"Arturo Ordaz" <el*****@hotmai l.com> wrote in message
news:7e******** *************** **@posting.goog le.com...

>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_fil e, "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.l earn.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
6959
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 errors. It uses fileperms() to get the permissions of the file, and it includes that info in any error message. Today I'm getting the following error message. I've used SmartFtp to go in and set the test file's permissions to 777, but in this error...
10
6750
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 "r+" mode, where the file will open for reading "+ also writing", but it will not create a new file if one isn't already there; it fails with an error. POSIX also has this behavior with it's 'open' call, you just leave the 'create' bit out, and...
1
2130
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 create a file if the file has been deleted. I would like to use fopen for its pointer return value to solve this.
145
6426
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 programs: /*** a.c ***/
7
3383
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 solve this. What is the best way to fix this problem?
8
5627
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 ( stderr, "cannot open file %s\n"); exit ( 1 ); }
0
10228
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11923
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
11722
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10158
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8550
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7706
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6504
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6665
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3840
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.