https://github.com/imranity/py-lslock
Python program to check locked files in a Dir.
https://github.com/imranity/py-lslock
Last synced: 23 days ago
JSON representation
Python program to check locked files in a Dir.
- Host: GitHub
- URL: https://github.com/imranity/py-lslock
- Owner: imranity
- Created: 2016-11-11T20:43:39.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-11-14T11:47:06.000Z (over 9 years ago)
- Last Synced: 2025-10-30T01:10:35.310Z (9 months ago)
- Language: Python
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# py-lslock
Show list of files locked with flock syscall for a given directory(passed as argument to program) on Linux.
### Overview
py-lslock uses `/proc/locks` file to read and determine which of files have been locked using flock.
NOTE: `/proc/locks` is a feature in linux kernel so this utility must be run on linux based system.
### Usage
Run the main program that list locks as following:
```python
python py-lslock.py /tmp/lslock-test
```
Here `/tmp/lslock-test` is given as argument where `.lock` files are checked.
### Test
To test, the test program must be run in separate shell.
Run as :
```python
python py-lslock-test.py /tmp/lslock-test 15
```
here 15 is number of iterations, i.e. # of lock operations performed in given subdirectory.
In other terminal run the main `py-lslock.py` to check the locked files in same directory.
```python
python py-lslock.py /tmp/lslock-test
```
###Sample output
```
root@imran-ThinkPad-W530:/home/imran/Desktop/py-lslock# python py-lslock.py /tmp/lslock
result of all locked files found in directory /tmp/lslock
LOCKED_FILE
/tmp/lslock/0.lock
/tmp/lslock/1.lock
/tmp/lslock/2.lock
/tmp/lslock/3.lock
/tmp/lslock/4.lock
/tmp/lslock/5.lock
/tmp/lslock/6.lock
/tmp/lslock/7.lock
/tmp/lslock/8.lock
/tmp/lslock/9.lock
/tmp/lslock/10.lock
```