LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 08-21-2002, 10:04 AM   #1
Nelleh
Member
 
Registered: Apr 2002
Distribution: SuSe/Redhat
Posts: 94

Rep: Reputation: 15
Multiple users writing to the same file


have to admit that I am not really too sure where this one lives.

I have written an assett tracking utility that writes to a single manifest file on certain actions.

What I would like to do is have several users using this utility and whilst the chances of it are fairly slim it would be possible to have two processes trying to write to the same file at the same time. Other than the obvious potential problem that this (maybe?) presents, there is also the issue that the script in question is reading data out of the file and incrementing a number by one before re-inserting the entry back into the manifest file.

are there any inbuilt checks within the system to prevent this occuring or would I just need to do something "basic" like renaming the file before I write any information into it and have all other processes checking for the existance of the file and waiting if it is not present?

ie process renames manifest to manifestinuse whilst it manipulated the data. Any subsequent processes check for manifest/manifestinuse and performs the relevant action (either write to file or wait an amount of time and recheck).
 
Old 08-21-2002, 02:13 PM   #2
Malicious
Member
 
Registered: Jan 2002
Location: Galveston Island
Distribution: suse, redhat
Posts: 208

Rep: Reputation: 30
You can use either fcntl() or flock() in the program to lock and unlock the file to protect against conflicting operations that would corrupt the data.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple users with the same name...users command buldir Linux - General 2 08-30-2004 04:34 PM
writing a script to perform a function on each users mail folder jhill Linux - Newbie 2 08-24-2004 07:18 AM
[FC2]Why does the users command display multiple users? Harkov Fedora 1 07-10-2004 09:24 PM
users writing in groups wedgeworth Linux - Newbie 5 06-04-2004 09:27 AM
need multiple users to have read/write access to a Quickbooks file at the same time. rbelknap Linux - Security 2 10-14-2003 10:52 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:20 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration