linenoise icon indicating copy to clipboard operation
linenoise copied to clipboard

make linenoiseEdit read resilient to signal

Open castorpilot opened this issue 11 years ago • 4 comments

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.

castorpilot avatar Jul 25 '14 13:07 castorpilot

Good catch, and good patch, but why <= 0 instead of == -1?

antirez avatar Jul 25 '14 13:07 antirez

No good reason. It really should be == -1. I'll change it.

castorpilot avatar Aug 05 '14 07:08 castorpilot

EWOULDBLOCK should also be added, for CTRL + c handling.

Asmod4n avatar Jul 03 '16 12:07 Asmod4n

Merged https://github.com/rain-1/linenoise/commit/65d4a4de53c5e7541e6cfd80c0b3fe759cce5639

rain-1 avatar May 15 '18 17:05 rain-1