mirror of
https://github.com/UzixLS/picocom.git
synced 2025-07-19 07:21:18 +03:00
Cancel linenoise input on signal, I/O error, or close (read 0).
When, while entering a line with linenoise, a signal is received or an input error is encountered, or the input channel is closed (read(2) returns 0), the operation is canceled as if the user had pressed C-c.
This commit is contained in:
@ -756,7 +756,12 @@ static int linenoiseEdit(int stdin_fd, int stdout_fd, char *buf, size_t buflen,
|
||||
char seq[3];
|
||||
|
||||
nread = read(l.ifd,&c,1);
|
||||
if (nread <= 0) return l.len;
|
||||
if (nread < 0) {
|
||||
return nread;
|
||||
} else if (nread == 0) {
|
||||
errno = EAGAIN;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Only autocomplete when the callback is set. It returns < 0 when
|
||||
* there was an error reading from fd. Otherwise it will return the
|
||||
|
Reference in New Issue
Block a user