Questions tagged [file-locking]

The concept of locking a file to serialize concurrent accesses to said file.

372 questions
5
votes
2 answers

Can I use FileStream to implement a file lock?

Can I use the FileStream constructor to ensure only one process accesses a file at a time? Will the following code work? public static IDisposable AcquireFileLock() { IDisposable lockObj; do { // spinlock - continually try to open…
thecoop
  • 45,220
  • 19
  • 132
  • 189
5
votes
1 answer

Java file locking way by multiple threads as well as multiple processes

I have more then 3 java processes accessing same file for read and write. Each process has multiple threads that read and write file very frequently (at the rate of 10 times or so in 1 second). I am using java.nio.channels.FileLock for interprocess…
5
votes
0 answers

Does Ionic ZipFile lock/unlock files?

I am busy developing an additional module for an existing C# (4.0) application that uses Ionic Zip library to manage the data. In my module I need to load data from zip files, manipulate them, and write back again. My routine runs OK in Unit Tests,…
user5788537
5
votes
1 answer

File lock between threads and processes

I'm writing a program that writes to a single file from both different threads on the same JVM and from different JVM's/processes. Is there a way to lock a file for both threads and processes, so that no matter how many threads/processes are trying…
Adam Rivers
  • 51
  • 1
  • 2
5
votes
1 answer

What is the following error in my Maven project? Access Denied

Error as shown in Marker: Error occured processing XML 'C:\Users\CHANDAN-G\Documents\workspace-sts-3.6.3.RELEASE\java-blog-aggregator\target\classes\com\chandan\blog\controller\IndexController.class (Access is denied)'. See Error Log for more …
Chandz
  • 1,173
  • 3
  • 18
  • 34
5
votes
1 answer

Locking behaviour is different via network shares

I have been trying to lock a file so that other cloned services cannot access the file. I then read the file, and then move the file when finished. The Move is allowed by using FileShare.Delete. However in later testing, we found that this approach…
MattH
  • 4,166
  • 2
  • 29
  • 33
5
votes
2 answers

Is a Java FileLock a POSIX advisory (fcntl) lock

I have a C++ program that locks files using POSIX advisory locks. That is, it uses the POSIX fcntl system call for lock operations. I want a Java program to interoperate with that C++ program, so I want my Java program to also use POSIX advisory…
Raedwald
  • 46,613
  • 43
  • 151
  • 237
5
votes
4 answers

How can my Linux daemon know when a Windows program has stopped writing a file that I access through SAMBA?

I'm developing a system that interfaces with a USPS shipping package called Dazzle. Part of this system includes a monitoring daemon whose purpose is to take tab-separated value files, turn them into XML that Dazzle recognizes, and pass them to…
Aurelia Peters
  • 2,169
  • 1
  • 20
  • 34
5
votes
2 answers

Why is PictureBox.Load locking image on some systems?

(Please see the edit on the bottom of the question, if you do not want to read the whole story.) Hi, I am new to stackoverflow. Don’t get me wrong, I use it quite often. But up until now I never actually posted something. This is because I did not…
user3379589
  • 51
  • 1
  • 4
5
votes
1 answer

How to lock a file in linux/unix by a java program?

I need to lock a file in unix/linux OS. I have googled and read about java.nio.channels Filelock and Reentrant File Lock . But both works in Windows but not in unix. Is there any other way of implementing a lock on file in unix? Any sample code…
user2910070
5
votes
4 answers

How do I check the exit code of a command executed by flock?

Greetings all. I'm setting up a cron job to execute a bash script, and I'm worried that the next one may start before the previous one ends. A little googling reveals that a popular way to address this is the flock command, used in the following…
Paul Accisano
  • 1,416
  • 1
  • 14
  • 25
5
votes
1 answer

Does FileChannel tryLock() method checks for locks or just breaks them?

I have two processes that may access the same file concurently and wanted to implement file locking. The trouble seems to be that one process is written in java and the other in C and it is not clear how low level locking is implemented on java…
homerski
  • 51
  • 3
5
votes
1 answer

How to manually Lock a file for other applications

I have spent quite some time figuring out how to do this but did not find any usefull solution. Here is what I want to do. I am generating a huge binary file in my application. The tricky thing is that, the process requires me to occasionally close…
Oliver Bernhardt
  • 399
  • 1
  • 4
  • 18
5
votes
2 answers

Delphi writing to a network share using TFilestream locks the file when network is lost

Im attempting to write to a network share (local) using TFilestream. It all works fine should the network connection not be interupted. However, if I pull the network cable and then reconnect it, subsequent attempts to open the filestream fail due…
Simon
  • 9,197
  • 13
  • 72
  • 115
4
votes
2 answers

How to make Emacs lock-buffer fail when it cannot lock a file?

I want to some Emacs lisp to manipulate same file from different Emacs processes. So I wrote the following script to check how lock-buffer works. However, it stops when trying to lock the file by the second Emacs process (find-and-lock-file $es2…
tkf
  • 2,990
  • 18
  • 32