joyent/node — Issue #2756: Follow up: Readline proposal
Author: Southern
Created: 2012-02-15 02:21:46+00:00
State: open

This is a follow up for #2737.

I have talked with @indutny, and we have agreed on the following as changes for the readline module.

Closing the input with `this.input.destroy()` would not be sufficient to solve the problem with the readline module hanging when it's closed. This is because returning a new interface from `rl.resume()` would cause users to have to reassign the interface. For example: `var rl = rl.resume(); rl.prompt();`, instead of `rl.prompt()` (where prompt would cause the stream to resume on its own).

We think it would be best to get rid of `rl.close()` altogether, and instead use only `rl.pause()` and `rl.resume()`. `rl.pause()` and `rl.resume()` will also emit a pause and resume event, in case users may want to trigger some functionality when the stream is paused or resumed.

This will not effect a user wanting to catch the SIGINT event when running readline, as readline already emits a SIGINT event if there is one present. If there is not a SIGINT event to be emitted, it then defaults to attempting to close the stream (which will be changed to a pause in the proposal).

Feedback, disagreements, or commentary welcome.

/cc: @isaacs @bnoordhuis