Browse Source

fix errno for posix_openpt with no free ptys available

linux fails the open with ENOSPC, but POSIX mandates EAGAIN.
Rich Felker 5 years ago
parent
commit
4fd0f20560
1 changed files with 3 additions and 1 deletions
  1. 3 1
      src/misc/pty.c

+ 3 - 1
src/misc/pty.c

@@ -7,7 +7,9 @@
 
 int posix_openpt(int flags)
 {
-	return open("/dev/ptmx", flags);
+	int r = open("/dev/ptmx", flags);
+	if (r < 0 && errno == ENOSPC) errno = EAGAIN;
+	return r;
 }
 
 int grantpt(int fd)