Terminate slcanpty when the pty file descriptor is closed instead of performing
an endless loop in the select() statement.
Reported-by: Janusz Uzycki <j.uzycki@elproma.com.pl>
Signed-off-by: Janusz Uzycki <j.uzycki@elproma.com.pl>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
int tmp, i;
nbytes = read(pty, &buf, sizeof(buf)-1);
- if (nbytes < 0) {
- perror("read pty");
+ if (nbytes <= 0) {
+ /* nbytes == 0 : no error but pty decriptor has been closed */
+ if (nbytes < 0)
+ perror("read pty");
+
return 1;
}