this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

sys_read() should return 0 instead of -EIO (Linux behavior) when PTY slave is closed

+15
+15
src/kernel/emulation/linux/unistd/read.c
··· 3 3 #include "../errno.h" 4 4 #include <linux-syscalls/linux.h> 5 5 #include "../bsdthread/cancelable.h" 6 + #include "../misc/ioctl.h" 7 + #include "../duct_errno.h" 8 + 9 + #define LINUX_TCGETA 0x5405 6 10 7 11 long sys_read(int fd, void* mem, int len) 8 12 { ··· 16 20 17 21 ret = LINUX_SYSCALL3(__NR_read, fd, mem, len); 18 22 if (ret < 0) 23 + { 24 + // When the slave side of a PTY is closed, Linux produces -EIO on the master side. 25 + // macOS produces an EOF. 26 + if (ret == -LINUX_EIO) 27 + { 28 + // Not making this static makes everything go boom. Do we have a too small stack somewhere? 29 + static char dummy[18]; 30 + if (__real_ioctl(fd, LINUX_TCGETA, dummy) == 0) // "isatty(fd)" 31 + return 0; 32 + } 19 33 return errno_linux_to_bsd(ret); 34 + } 20 35 21 36 return ret; 22 37 }