Questions tagged [lock]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
0answers
50 views

Unable to wake up after locking screen

Just installed Xubuntu 19.04. When I try to lock my screen it does some weird and crashes. Screen turns off and I have to turn the system off manually. Tried xscreensaver and it works just fine, but I ...
2
votes
2answers
140 views

Lock file naming pattern

Whenever I open a LibreOffice document, LibreOffice creates a lock file along the original file. This file has a naming schema like the following: .~lock.MyDocument.odt# Is this a LibreOffice ...
21
votes
3answers
2k views

How does this script ensure that only one instance of itself is running?

On 19 Aug 2013, Randal L. Schwartz posted this shell script, which was intended to ensure, on Linux, "that only one instance of [the] script is running, without race conditions or having to clean up ...
1
vote
0answers
31 views

About `page_table_lock` in Linux process address space

I'm reading a tutorial about Linux page table, in the linked page Each process has its own page tables (threads share them). The pgd field of the memory descriptor points to the process's page ...
3
votes
1answer
69 views

Lock Virtual Terminals when resuming

Many screen lockers (mine is i3lock) do not block access to other Virtual Terminals. This means that, if I leave a session opened in some VT, then even when the desktop is locked (for example when ...
0
votes
0answers
126 views

Does pid file work by assuming pid is not usable?

To use a pid file for ensuring singleton running instance of a program, I thought that when a process finishes running the program, it should remove the pid file, until I know it doesn't when reading ...
0
votes
1answer
33 views

Can we tell if a command is being run by a process or not, by looking at the flock lock file alone?

Is util-linux's flock implemented based on flock() in Linux C API? Can we tell if a command is being run by a process or not, by looking at the lock file alone? I found that when a command guarded by ...
2
votes
1answer
120 views

Is pseudo terminals ( unlockpt / TIOCSPTLCK ) a security feature?

After having opened the master part of a pseude-terminal int fd_pseudo_term_master = open("/dev/ptmx",O_RDWR); there is the file /dev/pts/[NUMBER] created, representing the slave part of he pseudo-...
-1
votes
1answer
61 views

Why “a lock file is the best approach if the resource is not a regular file, so using methods for locking files does not apply”?

Thanks to Mark's comment, pointing me to https://en.wikipedia.org/wiki/File_locking#Lock_files which says Shell scripts and other programs often use a strategy similar to the use of file locking: ...
0
votes
1answer
110 views

Allow DPMS to turn off screen with force when the screen is locked?

I discover that command xset dpms 300 which turn off the screen for example after 5 minutes (300s), and it wonderfully doesn't turn off the screen if a youtube video is actually playing even in a ...
1
vote
2answers
603 views

SELinux - How to avoid it preventing a process from write access on newly created files into folder

I'm hardly trying to correctly use selinux keeping it in enforced mode, but very often I encounter issues with it causing our application to work improperly. Our web application is java backend and ...
1
vote
1answer
51 views

Where is official documentation about locking mechanisms for etckeeper, apt, and/or dpkg?

Context: Want to put a lock on etckeeper/apt hook activity during special backup. Objective is to preserve whole package integrity, e.g., wait until any package installation is complete, and then ...
0
votes
2answers
40 views

Getting Information about locks associated with a process

I am unable to list the locks associated with a process and information about the locks i.e How many threads share this lock etc. Kindly tell my how to extract this information from a process ID. My ...
-1
votes
3answers
55 views

Locking user account in a specific way

I've been tasked with performing a lockdown on a user account (making it impossible to properly login-in to) in a very specific way. Im prohibited from: a) Altering his password (so passwd -l is out ...
1
vote
2answers
832 views

some other process automatically locks /var/lib/dpkg/lock for few minutes when restarting my system.

I am running Debian buster a.k.a. Debian testing. From the last couple of weeks, whenever I reboot the sytem i.e. going to CTRL+ALT+F1 and run $ sudo reboot it reboots the systems as normally but ...
1
vote
1answer
337 views

Create lock using unix socket/port

Is there a way to hold a lock a unix port using netcat or some other command? I want to do something like this: set -e; nc -lock 8000 & # this needs to fail if another process holds the lock ...
-1
votes
1answer
409 views

How can I simulate locking a file?

I would like to lock a file, run some tests then unlock the file. How can I do this. I could use the command line, perl, or a shell script. The reason I would like to lock the file is occasionally ...
1
vote
1answer
96 views

fcntl delete behaviour

I have a requirement to create locks via fcntl to make a script run only once with a given argument. To achieve this, I create a file with the given argument and acquire lock on it. I have the below ...
1
vote
1answer
211 views

Slackware 14.2 - black screen after waking from sleep/lock - what process controls sleep/lock?

I have had Slackware 14.2 32bit installed on a netbook with LXDE as my main DE for about a month now. My main issue is that sometimes the screen is black on waking from sleep [suspend] and the only ...
0
votes
1answer
74 views

Basic spinlock doubt

I read that in spinlock, process keeps on waiting for the lock continuously in a loop until it receives signal(lock) or release(lock) from other process. This causes busy waiting and hence CPU cycles ...
3
votes
2answers
9k views

How do I kill the process holding the apt lock?

I tried doing sudo apt update but got: Could not get lock /var/lib/apt/lists/lock - open (11: Resource temporarily unavailable) E: Unable to lock directory /var/lib/apt/lists/ I am trying ...
0
votes
1answer
1k views

Lock Usb Flash-Drive on Ubuntu Linux

By security request, I need to set up Ubuntu desktops from my network to not allow the use of flashdrives or USB storage devices. But the USB mouse and keyboard should normally be charged. Is there a ...
5
votes
1answer
4k views

Why flock doesn't clean the lock file? [closed]

After process is completed, I see that the lock file isn't deleted? Is there any reason that why flock keeps the file ? Also how does flock knows if there is a lock acquired ? Here is the example ...
2
votes
1answer
807 views

Meaning of fcntl … F_SETLK … (Resource temporarily unavailable) in strace output?

When I use straceon Apache while it acts unresponsive, I get the following output: [pid 13704] fcntl(57, F_SETLK, {type=F_RDLCK, whence=SEEK_SET, start=1073741824, len=1}) = -1 EAGAIN (Resource ...
3
votes
1answer
14k views

NFS mount: Device or resource busy

I referred the following link, the solution works. How to get over "device or resource busy"? The above solution works when you are manually deleting the file. But I have a python script ...
0
votes
1answer
660 views

Arch: safely save and restore pacman databases

I want to backup the pacman sync databases after an execution of pacman -Sy, creating "restore points" which pacman -Suu can use to reverse a failed system upgrade. Further background can be found ...
0
votes
0answers
47 views

atop - how to check what process locked folder during umount?

I have some software which unmounting folder during it's operation. But for some reason it can't do it. When I trying to umount folder manually (almost in same time) it does work. Can someone let me ...
3
votes
1answer
632 views

Check and Test Lock from other Process

I am trying to create a service wrapper (init.d script) around one of my favorite applications. The application creates both a PID and a lock file, and so I'm trying to use those to ensure that I can ...
2
votes
3answers
3k views

Does killing a process close all files opened by that process?

I want to kill a process which has an open connection to a database. If I kill the process, can I make sure that the database is unlocked?
1
vote
1answer
363 views

How to lock non-virtual terminal? Something like “vlock -a”"

There is an option with vlock to lock all pts/tty at a time which is, $ vlock -a But vlock can lock only virtual consoles. There is also an option named TMOUT which will terminate the current ...
2
votes
1answer
1k views

lock screen session suspension in debian jessie

lock screen session suspension in debian jessie I just read of an issue that seemed similar to mine, and as I cannot comment yet and my problem is different I will ask my question outright. the ...
0
votes
1answer
161 views

Duplication of a file descriptor associated with an fcntl lock?

According to the man page of dup2, this syscall make a new copy of the old file descriptor. The two descriptors do not share (the close-on-exec flag). However in case the file descriptor we are ...
2
votes
1answer
7k views

How to do locking a file from a shell script? [duplicate]

I would like to synchronize two Bash scripts via a file lock. How to do this? Zsh has zsystem flock call, but is there a more "shellish" method that's also available to Bash?
-2
votes
1answer
480 views

readonly file on linux

I want to lock a file(or read-only) so that anybody on server can't modify it. I find chattr command on Linux but I didn't use it for some reason. I am using mount --bind file.log file.log, but after ...
2
votes
0answers
441 views

How to use lockf on command line

I want to lock and unlock a file that resides in NFS share so I've found the reliable way is to go with lockf how can I use that in command line for flock I could do 'flock -s number' how can I do ...
3
votes
1answer
229 views

XScreenSaver: 1-2 seconds delay within which my laptop isn't locked

I want my screen to lock automatically and I'm using XScreenSaver. It locks the screen when my laptop suspends but when open the lid or press the power button, there's a small, 1-2 seconds delay and ...
2
votes
1answer
818 views

Does linux tar block write access to files

I have a large (>10GB) folder full of images on a live webserver that I need to back up and transfer. I'm worried that if I tar the folder, the files will be blocked for reading by the webserver, ...
3
votes
1answer
501 views

Bash, fork with CLOEXEC

Can Bash execute a subprocess while preventing a subprocess from inheriting a file descriptor? if flock -nx 9 then # If begin program runs away, it will keep the lock. begin program else echo "...
2
votes
0answers
295 views

Avoid starvation using flock with 2 process with write and read lock

I have two scripts let's call them script1 and script2. The script1 is scheduled every 2 minutes and it takes 4 minutes to execute the script2 is scheduled every 30 minutes and it takes 4 minutes to ...
0
votes
1answer
5k views

use of lockfile in script and it significance

I have a code in which below line is used due to which i got stuck.I have hunted the web but did not understand well.just got to know the basic set of info as below lockfile can be used to create one ...
4
votes
2answers
2k views

Linux file hierarchy - what's the best location to store lockfiles?

I want to synchronize processes based on lock files (/ socket files). These files should only be removable by their creator user. There are plenty of choices: /dev/shm /var/lock /run/lock /run/...
0
votes
1answer
1k views

Subversion E000037: Can't get exclusive lock on file 'db/txn-current-lock': No locks available

When I try to commit a change to a Subversion repository, and I get error messages of the form svn: E000037: Commit failed (details follow): svn: E000037: Can't get exclusive lock on file '/path/to/...
1
vote
1answer
44 views

Executing shell script parallelly and in background skips some operation

del_client.sh --delete client1 & del_client.sh --delete client2 & del_client.sh --delete client3 & del_client.sh --delete client4 & When I executed the commands above in the ...
-1
votes
1answer
107 views

Lock a Application Through Terminal

I was wondering if it were possible to lock a Application through Mac Terminal. I know there's a way to lock files, using chmod a+x 000 'directory', but it never worked with an Application. What I ...
0
votes
1answer
172 views

How do I check if a directory is locked or not in bash?

I have only been able to find solutions for files, and not directories, like lsof. chflags has no read option, so I don't know how to do it.
0
votes
1answer
712 views

Mandatory Locking in Unix

In Unix record locking is the technique used to lock the portion of a file for certain amount of time to maintain consistency of the data from concurrent access to the file. On this mechanism, ...
2
votes
2answers
2k views

apt-get wait for lock release

If you are running apt-get commands on terminal and want to install stuff on the software center, the center says it waits until apt-get finishes. I wanted to know if it is possible to do the same but ...
0
votes
1answer
445 views

Accidentally deleted lock folder

I executed the following command: sudo rm /var/lib/apt/lists/lock due to the solution I got from here. Now my system gets hanged more frequently while running several applications. I dont know if ...
4
votes
1answer
16k views

NFS file locking not working, am I misunderstanding?

I'm planning on having a complicated file sharing setup, and want to make sure I don't destroy file locking. (Wanting to use bind mounting, nfs, nfs over rdma (InfiniBand file sharing), and virtfs (...
1
vote
0answers
194 views

Is NFS file locking destroyed by the nfs server bind-mounting the directory being nfs shared?

I have a directory /persistent/pacmanPkgCache which is both: nfs-shared to other machines bind-mounted to /var/cache/pacman/pkg Does having this directory nfs-shared and bind-mounted at the same ...