Skip to content

Commit

Permalink
lib: fix eof() on Linux
Browse files Browse the repository at this point in the history
Linux, and probably others, will return -1 + EOF instead of 0.  Convert the
former to the latter to simplify things.

Signed-off-by: Kyle Evans <[email protected]>
  • Loading branch information
kevans91 committed Feb 9, 2024
1 parent 771e768 commit 00c64b3
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/core/orch_lua.c
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,14 @@ orchlua_process_read(lua_State *L)

/* Read it */
readsz = read(fd, buf, sizeof(buf));

/*
* Some platforms will return `0` when the slave side of a pty
* has gone away, while others will return -1 + EIO. Convert
* the latter to the former.
*/
if (readsz == -1 && errno == EIO)
readsz = 0;
if (readsz < 0) {
int err = errno;

Expand Down

0 comments on commit 00c64b3

Please sign in to comment.