Skip to content

Commit

Permalink
Break on reading 0 from ppp pty
Browse files Browse the repository at this point in the history
On some (all?) non-Linux systems, when select() returns pty master file
descriptor as ready to read, subsequent read() returns 0 if the slave
side fd has been closed, to indicate EOF. When this happens, break is
the correct course of action to avoid a potentially hazardous loop.

Fixes github issue #794
  • Loading branch information
Koston-0xDEADBEEF authored and DimitriPapadopoulos committed Jul 2, 2023
1 parent 1ccb8ee commit 74f63a9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ static void *pppd_read(void *arg)
break;
} else if (n == 0) {
log_warn("read returned %ld\n", n);
continue;
break;
} else if (first_time) {
// pppd did talk, now we can write to it if we want
SEM_POST(&sem_pppd_ready);
Expand Down

0 comments on commit 74f63a9

Please sign in to comment.