Socket
Book a DemoInstallSign in
Socket

ctrlc-exit

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ctrlc-exit

Exit the process when `Ctrl`+`C` is pressed

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

ctrlc-exit Build Status

Exit the process when Ctrl+C is pressed

Useful for CLI tools when default behavior to exit is disabled (e.g. raw mode is enabled).

Install

$ npm install ctrlc-exit

Usage

const ctrlcExit = require('ctrlc-exit');

ctrlcExit();

API

Using this prevents the process from exiting normally.

There are multiple ways you can handle this:

  • Call ctrlcExit.done() when you're done listening. It will then let the process exit normally.
  • Use process.stdin.unref() if you don't intend to use process.stdin afterwards. It will let the process exit normally.
  • Call process.exit() to exit the process directly.
  • esc-exit - Exit the process using Esc.

License

MIT © Vadim Demedes

Keywords

cli

FAQs

Package last updated on 11 Sep 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts