Registry / devops / siginfo

siginfo

JSON →
library0.10jsnpmunverified

siginfo is a Node.js utility module designed to abstract and standardize the handling of process information signals across different operating systems. Specifically, it normalizes `SIGINFO` (used on BSD/macOS) and `SIGUSR1` (used on Linux), both conventionally triggered by `Ctrl+T` to request a running process to output its internal state or progress. The current stable version is 2.0.0. This package provides a simple API that allows developers to register a callback function which executes when one of these signals is received, typically logging process-specific metrics like version, uptime, or progress. It differentiates itself by providing a cross-platform wrapper for a specific, widely-understood signal convention, making it easier to build inspectable long-running Node.js processes without dealing with OS-specific signal handling directly. Release cadence is infrequent, reflecting its stable and focused functionality, primarily updating for Node.js compatibility or minor enhancements.

npm install siginfo
INSTALL
IMPORT
SIG · SIGINFO
S
siginfo
devopsjavascriptv0.10
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

siginfo
const siginfo = require('siginfo')
import siginfo from 'siginfo'
Package v2.0.0 is CommonJS-first. ESM import is not directly supported without an adapter or bundler.
removeListener
const removeListener = siginfo(() => { /* ... */ })
The `siginfo` function returns a method to remove the signal listener.

Demonstrates setting up a `siginfo` listener to output process state (version, uptime, memory, custom metrics) when `Ctrl+T` (or the respective signal) is received.

const siginfo = require('siginfo'); const pkg = require('./package.json'); // Simulate some long-running process state let requestCounter = 0; setInterval(() => { requestCounter++; // console.log('Processing request', requestCounter); }, 500); const removeListener = siginfo(() => { console.log('\n--- Process Info (Ctrl+T) ---'); console.dir({ version: pkg.version, uptime: process.uptime(), memoryUsage: process.memoryUsage(), requestsProcessed: requestCounter, platform: process.platform, pid: process.pid }, { depth: 2 }); console.log('-----------------------------'); }); console.log(` Process started (PID: ${process.pid}). Press Ctrl+T (or send SIGINFO/SIGUSR1) to view status. `); // To stop listening after some time (optional) // setTimeout(() => { // removeListener(); // console.log('siginfo listener removed.'); // }, 60000);
Debug
Known issues
gotchaThe signals (`SIGINFO` on BSD/macOS, `SIGUSR1` on Linux) are typically only sent and processed when the Node.js process is connected to a TTY (terminal). If running in a background service or a non-interactive environment, the signal might not be received unless `force = true` is passed.
fix
If you need to receive signals in a non-TTY environment, pass `true` as the second argument: `siginfo(queryFn, true)`.
affects: >=1.0.0
gotchaThis module specifically targets `SIGINFO` (macOS/BSD) and `SIGUSR1` (Linux) as they are the conventional signals for requesting process information (e.g., `Ctrl+T`). Using `SIGUSR1` on macOS/BSD or `SIGINFO` on Linux might not yield the expected interactive `Ctrl+T` behavior or may conflict with other uses of these signals.
fix
Rely on the module's abstraction; it handles platform differences. Avoid manually sending signals like `kill -USR1 <pid>` on macOS if you expect `Ctrl+T` to trigger `SIGINFO`.
affects: >=1.0.0
gotchaThe `siginfo` function returns a `removeListener` function. If you register multiple listeners or run this in a context where the listener might become stale, not calling `removeListener()` can lead to memory leaks or unexpected behavior.
fix
Always store the return value of `siginfo()` and call `removeListener()` when the handler is no longer needed, especially in serverless or short-lived environments if the process might re-register handlers.
affects: >=1.0.0
breakingPrior versions (pre-1.0.0) might have had slight API variations or relied on older Node.js idioms. Version 2.0.0 refined the API to return the `removeListener` function directly.
fix
Ensure you are using the v2.0.0 API where `siginfo(fn)` returns `removeListener`. Review your code if upgrading from very old versions.
affects: <1.0.0
Errors
Common errors & fixes
TypeError: siginfo is not a function
Attempting to use ES module `import` syntax (`import siginfo from 'siginfo'`) with a CommonJS-only package in Node.js.
fix
Use CommonJS `require` syntax: `const siginfo = require('siginfo')`.
Signal handler not triggered when pressing Ctrl+T or sending signal.
The Node.js process is not connected to a TTY, or the `force` option was not used.
fix
Ensure the process is run from an interactive terminal, or explicitly enable forcing the listener: `siginfo(myFunction, true)`.
Upgrade
Version history
0.10latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
23 hits · last 30 days
node
20
OpenAI (training)
2
Resources