Skip to content
Advertisement

Tag: locking

Node.js – Asynchronously edit JSON file and prevent interferance from other async calls

I am making a Discord bot in node.js, and need to store some per-guild data. I want to store it in separate JSON files in data/<guild.id>.json using the built in fs/promises. I have a function setGuildData(guildID: string, dataToAssign: object) that reads the current JSON file, parses the JSON to fileData, then assigns the new data using Object.assign() to finally stringify

Delphi 10.3 Linux exclusive file access

How can I lock a file in Linux with a filestream? Creating a filestream like in the example below works perfectly in Windows, the file is locked and cannot be deleted or written to in other sessions until the stream is freed. Under Linux I can delete the file or write to it in an other session without any problems.

How to create a system-wide file lock?

I am trying to have a number of independent processes coordinate their writing to file using a system-wide lock (see here: Concurrent file accesses from different scripts python) The lock needs to span the whole system, because the processes are spawn independently and at different times. Here: System-wide mutex in Python on Linux I read that fcntl.lockf should do what

Read/Write lock for linux kernel module

I’m trying to protect my list with data using read/write locks, i found solution in this thread: What’s the best linux kernel locking mechanism for a specific scenario But i can’t find needed headers for this solution, seems it is outdated, error: error: ‘RW_LOCK_UNLOCKED’ undeclared here (not in a function) Using <linux/spinlock.h> Answer RW_LOCK_UNLOCKED has been deprecated for a long

ACID Transactions at the File System

Background: I am getting a temperature float from an arduino via a serial connection. I need to be able to cache this temperature data every 30 seconds for other applications (e.g. web, thermostat controller) to access and not overload the serial connection. Currently I cache this data to RAM as a file in /run (I’m trying to follow Linux convention).

fcntl, lockf, which is better to use for file locking?

Looking for information regarding the advantages and disadvantages of both fcntl and lockf for file locking. For example which is better to use for portability? I am currently coding a linux daemon and wondering which is better suited to use for enforcing mutual exclusion. Answer What is the difference between lockf and fcntl: On many systems, the lockf() library routine

Advertisement