mirror of
https://github.com/linux-can/can-utils.git
synced 2026-08-05 06:20:00 +02:00
slcanpty: detect that master PTY descriptor closed
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>
This commit is contained in:
+5
-2
@@ -75,8 +75,11 @@ int pty2can(int pty, int socket, struct can_filter *fi,
|
|||||||
int tmp, i;
|
int tmp, i;
|
||||||
|
|
||||||
nbytes = read(pty, &buf, sizeof(buf)-1);
|
nbytes = read(pty, &buf, sizeof(buf)-1);
|
||||||
if (nbytes < 0) {
|
if (nbytes <= 0) {
|
||||||
perror("read pty");
|
/* nbytes == 0 : no error but pty decriptor has been closed */
|
||||||
|
if (nbytes < 0)
|
||||||
|
perror("read pty");
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user