async-readline
async-readline copied to clipboard
Does not respond well to Ctrl-C, Ctrl-D or SIGKILL
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 :)
Looking at tokio-signal might be helpful there
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)
.