async-readline icon indicating copy to clipboard operation
async-readline copied to clipboard

Does not respond well to Ctrl-C, Ctrl-D or SIGKILL

Open KostaCitrix opened this issue 7 years ago • 2 comments

When I run cargo run --example readline and then press Ctrl-C or Ctrl-D, nothing happens.

I think this is missing the check for zero in lib.rs:127.

From the linux man page:

On success, the number of bytes read is returned (zero indicates end of file)

  • https://linux.die.net/man/2/read

I tried simply returning an Err::new(UnexpectedEof, ...) but that gets ignored. I'm not sure how to tell tokio to handle errors here but maybe you know :)

KostaCitrix avatar Dec 12 '16 10:12 KostaCitrix

Looking at tokio-signal might be helpful there

Kintaro avatar Dec 12 '16 10:12 Kintaro

Ctrl-D or Ctrl-C produce either a signal like @Kintaro said, or just some combination of keys. handle_char should be a proper state machine and detect such conditions, and make the futures::Stream finish by returning Ready(None).

dpc avatar Dec 12 '16 18:12 dpc