ctrlc-exit

2018-10-14 admin

ctrlc-exit是什么

什么是ctrlc-exit,Exit the process when Ctrl+C is pressed

ctrlc-exit使用教程帮助文档

ctrlc-exit Build Status

Exit the process when <kbd>Ctrl</kbd>+<kbd>C</kbd> 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.

Related

  • esc-exit - Exit the process using <kbd>Esc</kbd>.

License

MIT © Vadim Demedes

本站文章除注明转载外,均为本站原创或编译。欢迎任何形式的转载,但请务必注明出处。

转载请注明:文章转载自 JavaScript中文网 [https://www.javascriptcn.com]

本文地址:https://www.javascriptcn.com/read-42629.html

文章标题:ctrlc-exit

回到顶部