Title: Add an option not to trap SIGINT (Ctrl + C) to `readline.creatInterface` · Issue #61487 · nodejs/node · GitHub
Open Graph Title: Add an option not to trap SIGINT (Ctrl + C) to `readline.creatInterface` · Issue #61487 · nodejs/node
X Title: Add an option not to trap SIGINT (Ctrl + C) to `readline.creatInterface` · Issue #61487 · nodejs/node
Description: What is the problem this feature will solve? Here is a typical code to accepts multiple lines from stdin: import { stdin, stderr } from "node:process"; import { createInterface } from "node:readline/promises"; const rl = createInterface(...
Open Graph Description: What is the problem this feature will solve? Here is a typical code to accepts multiple lines from stdin: import { stdin, stderr } from "node:process"; import { createInterface } from "node:readlin...
X Description: What is the problem this feature will solve? Here is a typical code to accepts multiple lines from stdin: import { stdin, stderr } from "node:process"; import { createInterface } from &qu...
Opengraph URL: https://github.com/nodejs/node/issues/61487
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Add an option not to trap SIGINT (Ctrl + C) to `readline.creatInterface`","articleBody":"### What is the problem this feature will solve?\n\nHere is a typical code to accepts multiple lines from stdin:\n\n```js\nimport { stdin, stderr } from \"node:process\";\nimport { createInterface } from \"node:readline/promises\";\n\nconst rl = createInterface({ input: stdin, output: stderr });\n\nfor await (const line of rl) {\n // process line\n}\nconsole.log(\"Done\");\n```\n\nHowever, if you press Ctrl + C, it is treated as Ctrl + D—i.e. \"Done\" is displayed and you cannot cancel the multiline input. It is a ridiculous behavior.\n\n`await rl.question()` throws `AbortError` and messes up your terminal:\n\n```\n$ node ./test.mjs\nnode:internal/readline/interface:1331\n this[kQuestionReject]?.(new AbortError('Aborted with Ctrl+C'));\n ^\n\nAbortError: Aborted with Ctrl+C\n at [_ttyWrite] (node:internal/readline/interface:1331:37)\n at ReadStream.onkeypress (node:internal/readline/interface:284:20)\n at ReadStream.emit (node:events:508:28)\n at emitKeys (node:internal/readline/utils:371:14)\n at emitKeys.next (\u003canonymous\u003e)\n at ReadStream.onData (node:internal/readline/emitKeypressEvents:64:36)\n at ReadStream.emit (node:events:508:28)\n at addChunk (node:internal/streams/readable:559:12)\n at readableAddChunkPushByteMode (node:internal/streams/readable:510:3)\n at Readable.push (node:internal/streams/readable:390:5) {\n code: 'ABORT_ERR'\n}\n```\n\nIt is not sophisticated.\n\n### What is the feature you are proposing to solve the problem?\n\nAdd an option to `creatInterface` to prevent it from trapping `SIGINT` by default.\n\n```js\nconst rl = createInterface({ input: stdin, output: stderr, noTrapSigInt: true });\n```\n\nWith this, you will be able to press Ctrl + C to terminate the program immediately with the proper exit code.\n\n### What alternatives have you considered?\n\n```js\nimport { platform } from \"node:process\";\n\nrl.on(\"SIGINT\", () =\u003e {\n process.exit(platform === \"win32\" ? -1073741510 : 130);\n});\n```\n\nWhy do I have to add such a code? Who the hell can remember such numbers for both platforms?","author":{"url":"https://github.com/tats-u","@type":"Person","name":"tats-u"},"datePublished":"2026-01-23T06:53:01.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":9},"url":"https://github.com/61487/node/issues/61487"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:71e19e23-bff6-3aa1-30f3-031a87caec09 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D938:6DF5E:DB7F6F:126D862:6A4C5E56 |
| html-safe-nonce | 769ede8c006c8e05135bfbbd07e8f1c8cd329172aaa46ceb8a64809e78c52162 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEOTM4OjZERjVFOkRCN0Y2RjoxMjZEODYyOjZBNEM1RTU2IiwidmlzaXRvcl9pZCI6IjQ5NTk5MTE0MjAxMzA3Nzg3MTAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 9a5bae8fca7b9839214b77bea29170575910b7fd7f7b65b6133f695f33f48fbd |
| hovercard-subject-tag | issue:3846110238 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node/61487/issue_layout |
| twitter:image | https://opengraph.githubassets.com/813fe4659ad08155871170da9f182809f0314c49d3019321e343b4fdb58ac6fb/nodejs/node/issues/61487 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/813fe4659ad08155871170da9f182809f0314c49d3019321e343b4fdb58ac6fb/nodejs/node/issues/61487 |
| og:image:alt | What is the problem this feature will solve? Here is a typical code to accepts multiple lines from stdin: import { stdin, stderr } from "node:process"; import { createInterface } from "node:readlin... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | tats-u |
| hostname | github.com |
| expected-hostname | github.com |
| None | 3d11bb817438277de2a940854450e83a7d32b6aeb5014e9e6b00a6423900251c |
| turbo-cache-control | no-preview |
| go-import | github.com/nodejs/node git https://github.com/nodejs/node.git |
| octolytics-dimension-user_id | 9950313 |
| octolytics-dimension-user_login | nodejs |
| octolytics-dimension-repository_id | 27193779 |
| octolytics-dimension-repository_nwo | nodejs/node |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 27193779 |
| octolytics-dimension-repository_network_root_nwo | nodejs/node |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 14099438da5379150f15a2892474c7c7e6c0e55e |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width