aboutsummaryrefslogtreecommitdiffstats
path: root/vanilla/node_modules/siginfo/index.js
blob: 5092b6115d70e97ec511c1ed98e622f83eef9925 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
module.exports = function (query, force) {
  var isAttached = false
  if (process.stderr.isTTY || force === true) {
    isAttached = true
    process.on('SIGINFO', onsiginfo)
    process.on('SIGUSR1', onsiginfo)
  }

  return function () {
    if (isAttached === true) {
      process.removeListener('SIGINFO', onsiginfo)
      process.removeListener('SIGUSR1', onsiginfo)
      isAttached = false
    }
  }

  function onsiginfo () {
    query()
  }
}