Skip to content

Commit df54edc

Browse files
AnupamaPtargos
authored andcommitted
doc: document how to unref stdin when using readline.Interface
PR-URL: #38019 Fixes: #36154 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Darshan Sen <[email protected]>
1 parent d6346e1 commit df54edc

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

doc/api/readline.md

+12
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,17 @@ the best compatibility if it defines an `output.columns` property and emits
556556
a `'resize'` event on the `output` if or when the columns ever change
557557
([`process.stdout`][] does this automatically when it is a TTY).
558558

559+
When creating a `readline.Interface` using `stdin` as input, the program
560+
will not terminate until it receives `EOF` (<kbd>Ctrl</kbd>+<kbd>D</kbd> on
561+
Linux/macOS, <kbd>Ctrl</kbd>+<kbd>Z</kbd> followed by <kbd>Return</kbd> on
562+
Windows).
563+
If you want your application to exit without waiting for user input, you can
564+
[`unref`][] the standard input stream:
565+
566+
```js
567+
process.stdin.unref();
568+
```
569+
559570
### Use of the `completer` function
560571

561572
The `completer` function takes the current line entered by the user
@@ -891,3 +902,4 @@ const { createInterface } = require('readline');
891902
[`process.stdout`]: process.md#process_process_stdout
892903
[`rl.close()`]: #readline_rl_close
893904
[reading files]: #readline_example_read_file_stream_line_by_line
905+
[`unref`]: net.md#net_socket_unref

0 commit comments

Comments
 (0)