472,983 Members | 2,497 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

multiple open fd's on open(file)

Hi,

When you open a file for writing/appending with open() or fopen(), and
you have multiple applications that might want to write to the same file
at the same time, could that cause weirdness in the file ?

do i have to add manual file locking, or does open()/fopen() provide
file locking ?

Thanks,
Corne'

Nov 13 '05 #1
2 6449
> When you open a file for writing/appending with open() or
fopen(), and you have multiple applications that might want to
write to the same file at the same time, could that cause
weirdness in the file ?


This question sounds off topic for this group.

Have you asked in comp.unix.programmer?

Nov 13 '05 #2
Corne' Cornelius <co***@no-domain-no-spam.com> wrote:
When you open a file for writing/appending with open() or fopen(), and
you have multiple applications that might want to write to the same file
at the same time, could that cause weirdness in the file ?
First of all, open() isn't a standard C function, so you won't get
an answer here about its behavior, the question can only be answered
in the context of your system that might or might not implement an
open() function. And for fopen() the answer is also simple: since
standard C doesn't doesn't know or care about other processes
running concurrently, there's no requirement that any kind of file
locking is implemented for fopen().
do i have to add manual file locking, or does open()/fopen() provide
file locking ?


Unless your implementation of the C standard library does file locking
for you (which I would rather doubt) you do have to do it yourself.
Otherwise, as you guess, you might end up with the output of the
different applications mixed up in the file in possibly completely
unpredictable ways - but that's of course again depending of how your
operating systems schedules the processes, which isn't something C
is (or should be) concerned with.

Probably it would also be quite a stupid idea to automatically do
file locking when a file is opened with fopen() because it would
keep you from implementing your own scheme - you might actually
want to have two applications write to the same file, using your
own method to keep the applications from writing in uncoordinated
ways to the file, e.g. in a situation where simple file locking
wouldn't be fine grained enough.
Regards, Jens
--
_ _____ _____
| ||_ _||_ _| Je***********@physik.fu-berlin.de
_ | | | | | |
| |_| | | | | | http://www.physik.fu-berlin.de/~toerring
\___/ens|_|homs|_|oerring
Nov 13 '05 #3

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

Similar topics

10
by: 3A Web Hosting | last post by:
Hi Is it possible to perform multiple file uploads via a form? It's no problem uploading single files but I want to be able to highlight a group of files and upload them all in one go. My...
0
by: Gary Robinson | last post by:
For some code I'm writing, it's convenient for me to have multiple file objects (say, 2 or 3) open on the same file in the same process for reading different locations. As far as I can tell,...
0
by: Pradyumna | last post by:
I have an application wherein I need to select multiple files. I am using a CFileDialog class for opening the 'Open file dialog' . However i cant seem to select more than 2605 files. I mean i can...
1
by: Avin Patel | last post by:
Hi, I am looking for script to allow multiple files can be uploaded/attached in webform ( mostly cgi/perl or php). But I don't like the multiple input boxes using "<input type="file" size="40"...
0
by: Yandos | last post by:
Hello all, I'm sorry for a bit off-topic post, but curl does not have own newsgroup, so I hope someone might help me here... I need to feed form like the following using libcurl: <form...
6
by: Gaijinco | last post by:
I'm having a weird error compiling a multiple file project: I have three files: tortuga.h where I have declared 5 global variables and prototypes for some functions. tortuga.cpp where I...
1
by: feltra | last post by:
Hi, The following is from my friend who has only restricted net access from his office and hence cannot post.... ...
0
by: feltra | last post by:
Hi all, I am trying to export a GridView data to multiple file formats. The requirement is that when more than one file format is selected and the "Submit" button is clicked, the data from the...
3
by: Ecohouse | last post by:
I know how to use the File Dialog control but I'm not sure how to actually open the file that is selected. Here's my code: 'Create a FileDialog object as a File Picker dialog box. Set fd =...
2
by: klia | last post by:
Hello guys i was wondering how can i be able to have multiple file selection whenever i browse my directory and choose files using Qfiledailoug this is the code to lunch the file dailoug ...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.