Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnu Pasumarthy <anupama.pasumarthy@gmail.com>2021-04-01 16:09:11 +0300
committerAntoine du Hamel <duhamelantoine1995@gmail.com>2021-04-03 20:55:00 +0300
commit7980d7cc847105d10f7dbf70fe09dd7ec1c6cf3f (patch)
treef8e36361fe67116be3998fb163355c3dd744e1f2 /doc/api/readline.md
parent0828a96c10d12a3b2f45949ed376ffbbf3fba37f (diff)
doc: document how to unref stdin when using readline.Interface
PR-URL: https://github.com/nodejs/node/pull/38019 Fixes: https://github.com/nodejs/node/issues/36154 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com>
Diffstat (limited to 'doc/api/readline.md')
-rw-r--r--doc/api/readline.md12
1 files changed, 12 insertions, 0 deletions
diff --git a/doc/api/readline.md b/doc/api/readline.md
index 5081dc713fe..18e84389c6c 100644
--- a/doc/api/readline.md
+++ b/doc/api/readline.md
@@ -633,6 +633,17 @@ the best compatibility if it defines an `output.columns` property and emits
a `'resize'` event on the `output` if or when the columns ever change
([`process.stdout`][] does this automatically when it is a TTY).
+When creating a `readline.Interface` using `stdin` as input, the program
+will not terminate until it receives `EOF` (<kbd>Ctrl</kbd>+<kbd>D</kbd> on
+Linux/macOS, <kbd>Ctrl</kbd>+<kbd>Z</kbd> followed by <kbd>Return</kbd> on
+Windows).
+If you want your application to exit without waiting for user input, you can
+[`unref`][] the standard input stream:
+
+```js
+process.stdin.unref();
+```
+
### Use of the `completer` function
The `completer` function takes the current line entered by the user
@@ -968,3 +979,4 @@ const { createInterface } = require('readline');
[`process.stdout`]: process.md#process_process_stdout
[`rl.close()`]: #readline_rl_close
[reading files]: #readline_example_read_file_stream_line_by_line
+[`unref`]: net.md#net_socket_unref