fix errno for posix_openpt with no free ptys available
authorRich Felker <dalias@aerifal.cx>
Tue, 22 Oct 2019 14:22:22 +0000 (10:22 -0400)
committerRich Felker <dalias@aerifal.cx>
Thu, 24 Oct 2019 14:25:09 +0000 (10:25 -0400)
linux fails the open with ENOSPC, but POSIX mandates EAGAIN.

src/misc/pty.c

index b9cb5ea..a057714 100644 (file)
@@ -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)