mirror of
https://github.com/zebrajr/node.git
synced 2025-12-07 00:20:38 +01:00
PR-URL: https://github.com/nodejs/node/pull/59040 Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
30 lines
636 B
JavaScript
30 lines
636 B
JavaScript
'use strict';
|
|
|
|
const { isMainThread } = require('worker_threads');
|
|
const {
|
|
ERR_WORKER_UNSUPPORTED_OPERATION,
|
|
} = require('internal/errors').codes;
|
|
|
|
let sigintWatchdog;
|
|
function getSigintWatchdog() {
|
|
if (!sigintWatchdog) {
|
|
const { SigintWatchdog } = require('internal/watchdog');
|
|
sigintWatchdog = new SigintWatchdog();
|
|
}
|
|
return sigintWatchdog;
|
|
}
|
|
|
|
function setTraceSigInt(enable) {
|
|
if (!isMainThread)
|
|
throw new ERR_WORKER_UNSUPPORTED_OPERATION('Calling util.setTraceSigInt');
|
|
if (enable) {
|
|
getSigintWatchdog().start();
|
|
} else {
|
|
getSigintWatchdog().stop();
|
|
}
|
|
};
|
|
|
|
module.exports = {
|
|
setTraceSigInt,
|
|
};
|