Comments (4)
This module already makes a best-effort attempt to unlock files on process exit.
https://github.com/npm/lockfile/blob/master/lockfile.js#L33-L37
from lockfile.
Thanks for reply, but when I taskkill the process, the unlock didnt work.
Maybe I misunderstood the use case of file lock?
I want to lock a user file after user login,
and make sure the lock removed when the same process quit (including taskkill, etc)
from lockfile.
The process.on('exit')
event doesn't fire if the process is killed by a unix signal.
You can use the module signal-exit, and add this:
var signalExit = require('signal-exit')
signalExit(function (code, signal) {
if (signal)
process.emit('exit')
})
var lockfile = require('lockfile')
// do whatever with lock files
Doing this requires that the program add os-level listeners to every possible fatal signal, and do some other hoop-jumping to make sure it doesn't accidentally prevent the exit when the signal should be fatal. That's what the signal-exit
module does, but it would be excessive to do that in this module.
from lockfile.
Thanks! But I guess some of these signals are inavailable in Windows, :/ as well as killing the process from task monitor?
from lockfile.
Related Issues (20)
- unlocking an already-unlocked( or not-locked) lock in current process is not really a no-op. HOT 6
- No changelog
- Unlink error not passed to callback HOT 3
- check returns always true in OSX? HOT 1
- Avoiding writeFile collisions? HOT 2
- Catch exit by Ctrl+C HOT 2
- LOL not sure what just happened HOT 3
- Bug in project => TypeError: cb is not a function HOT 2
- Works as intended across processes ? HOT 1
- getting weird error - EEXIST: file already exists, open '/x/y/z.lock' HOT 5
- Library does not seem to fulfill contract HOT 12
- Question: How to wait until file lock is removed HOT 2
- acquiring same lock but with different stale should fail HOT 1
- How to set lifetime for the lock?
- test staleness-sync-test failing on arm32
- Support Promise API HOT 3
- [FEATURE] Refresh Locks HOT 1
- Type definition lists callback parameter options as Error | null. However, I observe undefined
- [FEATURE] Add more context in error messages
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lockfile.