doc: document how to unref stdin when using readline.Interface · nodejs/node@b40d35d

Original file line numberDiff line numberDiff line change

@@ -633,6 +633,17 @@ the best compatibility if it defines an `output.columns` property and emits

633633

a `'resize'` event on the `output` if or when the columns ever change

634634

([`process.stdout`][] does this automatically when it is a TTY).

635635
636+

When creating a `readline.Interface` using `stdin` as input, the program

637+

will not terminate until it receives `EOF` (<kbd>Ctrl</kbd>+<kbd>D</kbd> on

638+

Linux/macOS, <kbd>Ctrl</kbd>+<kbd>Z</kbd> followed by <kbd>Return</kbd> on

639+

Windows).

640+

If you want your application to exit without waiting for user input, you can

641+

[`unref`][] the standard input stream:

642+
643+

```js

644+

process.stdin.unref();

645+

```

646+
636647

### Use of the `completer` function

637648
638649

The `completer` function takes the current line entered by the user

@@ -968,3 +979,4 @@ const { createInterface } = require('readline');

968979

[`process.stdout`]: process.md#process_process_stdout

969980

[`rl.close()`]: #readline_rl_close

970981

[reading files]: #readline_example_read_file_stream_line_by_line

982+

[`unref`]: net.md#net_socket_unref