{"library":"siginfo","title":"SIGINFO/SIGUSR1 Signal Handler","description":"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.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install siginfo"],"cli":null},"imports":["const siginfo = require('siginfo')","const removeListener = siginfo(() => { /* ... */ })"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"const siginfo = require('siginfo');\nconst pkg = require('./package.json');\n\n// Simulate some long-running process state\nlet requestCounter = 0;\nsetInterval(() => {\n  requestCounter++;\n  // console.log('Processing request', requestCounter);\n}, 500);\n\nconst removeListener = siginfo(() => {\n  console.log('\\n--- Process Info (Ctrl+T) ---');\n  console.dir({\n    version: pkg.version,\n    uptime: process.uptime(),\n    memoryUsage: process.memoryUsage(),\n    requestsProcessed: requestCounter,\n    platform: process.platform,\n    pid: process.pid\n  }, { depth: 2 });\n  console.log('-----------------------------');\n});\n\nconsole.log(`\nProcess started (PID: ${process.pid}). Press Ctrl+T (or send SIGINFO/SIGUSR1) to view status.\n`);\n\n// To stop listening after some time (optional)\n// setTimeout(() => {\n//   removeListener();\n//   console.log('siginfo listener removed.');\n// }, 60000);\n","lang":"javascript","description":"Demonstrates setting up a `siginfo` listener to output process state (version, uptime, memory, custom metrics) when `Ctrl+T` (or the respective signal) is received.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}