fix: do not subscribe to SIGINT signal unless lock is acquired (#19978)
Subscription to SIGINT handler removes default handler. Fixes #19418
This commit is contained in:
parent
6022a4098f
commit
9943bcfcd8
|
|
@ -382,15 +382,23 @@ function toPromise(method) {
|
||||||
|
|
||||||
// Remove acquired locks on exit
|
// Remove acquired locks on exit
|
||||||
/* istanbul ignore next */
|
/* istanbul ignore next */
|
||||||
onExit(() => {
|
let cleanupInitialized = false;
|
||||||
for (const file in locks) {
|
function ensureCleanup() {
|
||||||
const options = locks[file].options;
|
if (cleanupInitialized) {
|
||||||
|
return;
|
||||||
try { options.fs.rmdirSync(getLockFile(file, options)); } catch (e) { /* Empty */ }
|
|
||||||
}
|
}
|
||||||
});
|
cleanupInitialized = true;
|
||||||
|
onExit(() => {
|
||||||
|
for (const file in locks) {
|
||||||
|
const options = locks[file].options;
|
||||||
|
|
||||||
|
try { options.fs.rmdirSync(getLockFile(file, options)); } catch (e) { /* Empty */ }
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
module.exports.lock = async (file, options) => {
|
module.exports.lock = async (file, options) => {
|
||||||
|
ensureCleanup();
|
||||||
const release = await toPromise(lock)(file, options);
|
const release = await toPromise(lock)(file, options);
|
||||||
return toPromise(release);
|
return toPromise(release);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue