571 questions
Score of 1
1 answer
80 views
How to work around Linux's lack of mandatory file locking?
In Windows, the CreateFile function has a sharing mode, which you can use to prevent other processes from opening files or writing to files you are currently operating on. The same mechanism was ...
Score of 0
0 answers
112 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 = ...
Score of 2
0 answers
154 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 ...
Score of 1
1 answer
88 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 ...
Score of -1
1 answer
95 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. ...
Score of 0
3 answers
199 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
...
Score of -1
1 answer
66 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 ...
Score of 1
0 answers
314 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"...
Score of 0
2 answers
194 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 ...
Score of 1
2 answers
94 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....
Score of 1
1 answer
1116 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 ...
Score of 0
1 answer
150 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). ...
Score of 0
1 answer
103 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 ...
Score of 1
1 answer
102 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 ...
Score of 0
1 answer
325 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 ...