linenoise
linenoise copied to clipboard
make linenoiseEdit read resilient to signal
Read in a loop and allow retry if read was interrupted by a signal.
Rationale : I use linenoise in a piece of code that uses posix timers (bound to realtime signal). Every time the timer fires, read returns -1 and errno is set to EINTR. This causes linenoise to think that an empty line was read, and this closes my interactive session. This patch prevents this from happening : a signal just causes read to retry.
Good catch, and good patch, but why <= 0 instead of == -1?
No good reason. It really should be == -1. I'll change it.
EWOULDBLOCK should also be added, for CTRL + c handling.
Merged https://github.com/rain-1/linenoise/commit/65d4a4de53c5e7541e6cfd80c0b3fe759cce5639