571 questions
0
votes
0
answers
107
views
Why does File.Move sometimes fail (rare target file lock / race condition / bug)?
The following .NET 8 targetted code (formatted as xunit test) fails on my machine (Windows 11), typically j is something between 50 and 100.
[Fact]
void FileMoveException()
{
var sourceFilePath = ...
2
votes
0
answers
144
views
Process synchronization using advisory locking
I'm trying to do an exercise from Advanced Programming in the UNIX Environment where I need to:
Open a file that contains a counter.
Fork a process.
Have the parent and child increment the counter ...
1
vote
1
answer
76
views
Is `flock` per-OFD or per-process-per-file?
man 2 flock on Linux says:
[L1]
Locks created by flock() are associated with an open file description (see
open(2)). This means that duplicate file descriptors (created by, for ...
-1
votes
1
answer
88
views
Linux: file locking from python script which is running inside docker container
Current situtation:
I am running a docker container on a WAGO PFC200 PLC (custom embedded linux firmware).
The container runs a python script which collects systeminfo like cpu load, memory usage etc. ...
0
votes
3
answers
189
views
What in my code is locking the database file, preventing me to backup?
I have these methods to backup my SQLite database and upload it to my blob container:
public static async Task<string> CreateBackupAsync()
{
// Generate the timestamped backup file name
...
-1
votes
1
answer
62
views
delete a jvm-locked file on jvm exit [duplicate]
I have a file that is under lock by the JVM (it is a jar file that provides classes that are loaded at some point during runtime). When my program exits I want to delete this file. However, simply ...
1
vote
0
answers
298
views
How to correctly delete abandoned Python filelocks on Linux
As mentioned elsewhere, Python's FileLocks do not delete themselves after being released on Linux ([1][2]). This fails:
import os
from filelock import FileLock
with FileLock("/tmp/test.lock"...
0
votes
2
answers
165
views
locking a file accessed by concurrent processes
I need to write to and read from a config file using shell CGI, and I also have a C program that must read and modify the config file every few seconds. I tried using flock to maintain data integrity ...
1
vote
2
answers
92
views
Check for open file and retry operation
Using powershell, i have this code block
ForEach ($Filepath in $BaselineFile_NME,$DailyOutputFile_NME)
{
$SHA1 = [Security.Cryptography.HashAlgorithm]::Create( "SHA1" )
$stream_HSH = ([IO....
1
vote
1
answer
1k
views
linux mandatory locking for file locking
I want to test mandatory locking in linux (Ubuntu 22.04.2 LTS) and I do the following steps
1- mount /dev/vgg1/lvv11 /u03 -o mand
2- chmod g+s /u03/datafile.dbf
3- chmod g-x /u03/datafile.dbf
and then ...
0
votes
1
answer
135
views
Java's FileLock allows to lock twice
In Java on Ubuntu, I'm using a FileLock to lock a file. The problem regularly happens on a server that runs on Debian. To make it easily reproducible, I wrote a minimal sample application (see below). ...
0
votes
1
answer
101
views
Change CreateFileW dwShareMode
Is there a way to use CreateFileW and with FILE_SHARE_WRITE and then after a while change that to only FILE_SHARE_READ?
I could not find any documentation, but it seems memory map files can elevate ...
1
vote
1
answer
99
views
Prevent file deletion, but allow to copy
I need to lock a file using Java to prevent file deletion by another process, but allow copying of this file. It should be made by two methods like lock() and unlock().
I tried using a FileLock, but ...
0
votes
1
answer
309
views
GetSecurityDescriptor parameters
I was looking for a function to find the username locking a file.
I found this one which works fine:
Function GetUsername(fileDir As String, fileName As String) As String
'On Error Resume Next
Dim ...
1
vote
1
answer
223
views
Meaning of CF_OPEN_FILE_FLAG_FOREGROUND flag with CfOpenFileWithOplock
The flag CF_OPEN_FILE_FLAG_FOREGROUND is not documented in either the documentation for CF_OPEN_FILE_FLAGS nor in the documentation for CfOpenFileWithOplock.
What is this flag's meaning?
0
votes
0
answers
116
views
Java file sharing/byte range locking
I need to be able to have multiple processes accessing a single file such that there is at most one writer but potentially multiple readers that have the file open at the same time (enforced at file ...
1
vote
2
answers
746
views
Ignite Server pod unable to acquire lock to file
I am debugging an issue with one of our Ignite servers which was running in Kubernetes for some months without issue.
Client nodes started failing to come up as as they were failing a readiness probe ...
0
votes
1
answer
217
views
Powershell script open textfile with executable and lock textfile
I am trying to write a powershell script which open a textfile with an executable like notepad++ and lock the textfile on readmode, so nobody overwrite my changes while I'm working.
$lockFile = 'C:\...
1
vote
1
answer
442
views
liquibase.lockservice.StandardLockService.waitForLock
related: Issue on github: https://github.com/broadinstitute/cromwell/issues/7009
I'm using a bioinformatics java program named cromwell (https://github.com/broadinstitute/cromwell/) which, as far as I ...
2
votes
0
answers
157
views
FileChannel.tryLock works locally but hangs on remote machine, accessed via SSH
Tl;DR code with FileChannel.tryLock works on a local file but hangs indefinitely when run on a remote machine, I had SSHed into. Most of the length of this question is about showing outputs and ...
0
votes
1
answer
116
views
FileLock for two exclusive processed
Windows supports LockFile function for applying exclusive locks on a file, and the LockFileEx functions for applying an exclusive locks and shared read for all processes.
Is it possible to have ...
0
votes
1
answer
1k
views
GCP storage - lock object/file stored in GCP bucket
I am getting a data file from source system. once file received in GCP bucket we start processing that file. How to lock this file till the processing is completed? so no other file processor (app) ...
0
votes
1
answer
19
views
Changes made are not reversing
I was trying to build a simple program that blocks the websites for a given time. The websites are listed in a txt file that I have locked for security reasons. This was my first time experimenting ...
1
vote
1
answer
782
views
How does a FileLock work over the network? Will it only lock a local file in the mount, or will the lock "propagate" to the file on another machine?
Okay, so I'm unsure how mounts over a network work with file locks.
This is the scenario:
There are two JVMs, each running on a machine of its own (both Linux).
Then there is a file share, on a third ...
0
votes
0
answers
207
views
How to acquire lock on a file located at a NAS mount path across multiple JVMs running on different servers in Java/ Spring Boot
How to acquire lock on a file located at a NAS mount path across multiple JVMs running on different servers in Java/ Spring Boot.
Tried FileSystemPersistentAcceptOnceFileListFilter. It picked up the ...
0
votes
1
answer
576
views
Safely use pickle "database" from multiple processes
I need a very simple persistent storage in my Python application. Usually, I just make a dict and store it with pickle or json when it changes, and then read it back at startup. This only works when ...
0
votes
0
answers
372
views
How do I unlock an Excel file that's been locked by code?
I'm using Windows 7 professional, Visual Studio 2012, and vb.net. This is a legacy program that can't be moved from this machine, so I'm unable to change where it's hosted.
I was attempting to read in ...
0
votes
0
answers
115
views
RandomAccessFile.close releases file locks for all threads on Linux OpenJDK 8
After investigating a bug, I found out that when Thread-B calls RandomAccessFile.close on a file (after failing a RandomAccessFile.getChannel().tryLock() call), the closing either closes all open ...
1
vote
1
answer
1k
views
What is the difference between open with O_EXCL and using flock
Imagine I have two processes trying to open the same file in read only mode. I want only one process to open the file and the other one to fail (essentialy a file lock). What is the difference between ...
0
votes
2
answers
2k
views
Java FileLock issues on Linux NFS
I am using Java's file locking API on a Linux server machine and try to lock a file on a remote Linux NFS system. There are some issues that have popped and logs show that 2 different cluster nodes ...
1
vote
0
answers
356
views
TeamCity doesn't release file locks after a cancelled build
We are using an Enterprise version of TeamCity 2017. We experience an issue that is reproduced like this:
Start a build
Immediately cancel it
Start a build
at this point, an exception in TeamCity ...
2
votes
1
answer
1k
views
java nio FileLock.release() throws ClosedChannelException and truncates my file
I've got e:\myfile.txt with some random contents:
abcabcxyz...abc
Then I try to use nio FileLock like below:
import java.io.*;
import java.nio.channels.*;
public class FileLockTest{
public static ...
0
votes
0
answers
989
views
Access is denied error while moving file using MoveFileEx on Windows
I am using MoveFileEx() API to move an existing file to a new file. I'm executing below program multiple times via a script.
Below program creates a unique file on every execution, and moves it to ...
0
votes
1
answer
1k
views
Dart/Flutter lock File for read and write
since this a rather usual Problem, I think I am missing something easy, but:
How can I lock a (text) file "fileFrom" in dart, to read the content, write it to another file "fileTo" ...
1
vote
1
answer
160
views
File locking in Clojure
I'm using Java FileLock to lock files in Clojure (on macOS). This is my code to acquire a lock:
(defn lock-file
[file-path]
(try
(let [file (io/file file-path)
channel (.getChannel (...
-1
votes
2
answers
304
views
Characters added to the bottom of .yaml files accessed by multiple processes
I make a YAML file as a configuration file and read and write python code through the YAML library.
However, this YAML file is read and written by multiple processes, but sometimes the file is ...
0
votes
0
answers
504
views
How I can check lease status before acquiring lease on file in azure fileshare?
Below is my code to acquire lease on file in azure fileshare. Before acquiring lease, I need to check lease status of file.
var shareClient = new ShareClient(connectionString, "testfileshare"...
1
vote
1
answer
140
views
TCL Blowfish behavior
I made a small script that zips a file and then encrypts that file:
#-- cut from proc --
set outfile [open $out wb]
set ind [string last \/ $in]
set in [string range $in [expr $ind + 1] end]
zipfile::...
0
votes
1
answer
745
views
How can I unlock file in c
I tried to lock-unlock file in c. If the file is exist then there is no problem but if file does not exist and file is created, file stays locked. If I tried to open the file, It did not open. It says ...
0
votes
0
answers
174
views
Do I need FileLock to read a file that is being written by other batch of processes using file-locking?
I have a bunch of processes accessing and modifying a csv file from Python at the same time (safely doing so with FileLock). I access the file using the Pandas package.
I would like to launch another ...
0
votes
0
answers
120
views
PowerShell: waiting for output redirect file to unlock after killing process
I have a PowerShell script that:
Starts a new process and redirects the output to two files
Waits with a timeout for the process to complete
Kills the process if it timed out
Reads the contents from ...
0
votes
2
answers
2k
views
tldextract: Timeout: The file lock 'some/path/to/8738.tldextract.json.lock' could not be acquired
I've been using tldextract for a while in my multiprocess, multithreaded script and it never caused any problems.
Now, it's giving me this error message and I've got no idea where to start looking for ...
0
votes
2
answers
317
views
FileVersionInfo.GetVersionInfo not letting go of file
I'm trying to check the version of the Windows application the user is running against the version that is on the server to see if the local version needs to be updated. I do this by calling
...
0
votes
0
answers
312
views
Application run by Process.Start blocking files even after Close and end of Using
I am running an application in a loop using Process.Start sometimes that application gets stuck (can't modify it) and I shut it down with .Close() if it hasn't update. However, the application creates ...
0
votes
1
answer
1k
views
How to filelock an entire directory?
I want to lock a directory and its contents, to allow only one process writing in it.
To do that, I'm using the Portalocker library, and a file called .lock
from pathlib import Path
import os
import ...
0
votes
0
answers
849
views
How to restore locked files to unlocked status (Windows 11 Home)
I have done a stupid thing and need help getting bailed out. I installed a file/folder lock app "EaseUS LockMyFile" (Windows 11 Home). I locked a couple of folders but wasn't happy with the ...
3
votes
1
answer
1k
views
git (git-bash) on windows locks number of folders even when done
I usually use git-bash to manage source code from my windows desktop. When I am done, I close the git-bash window or run the exit command.
Then, I noticed that a good number of folders used for git ...
0
votes
0
answers
343
views
How to share the files (files object) between the various processes in python?
I'm implementing the multiprocessing, there are lot of JSON files, I want to read and write those files by various processes, I'm doing multiprocessing. I don't want the race condition in between so ...