aboutsummaryrefslogtreecommitdiffstats
path: root/main/musl/fix-errno-for-posix_openpt-with-no-free-ptys-availab.patch
blob: a7afdd3dbd3f079430e93d6c830faea0ee784cc4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
From 4fd0f2056082441a4503f6bfcb787a7c15754518 Mon Sep 17 00:00:00 2001
From: Rich Felker <dalias@aerifal.cx>
Date: Tue, 22 Oct 2019 10:22:22 -0400
Subject: [PATCH] fix errno for posix_openpt with no free ptys available

linux fails the open with ENOSPC, but POSIX mandates EAGAIN.
---
 src/misc/pty.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/misc/pty.c b/src/misc/pty.c
index b9cb5eaa..a0577147 100644
--- a/src/misc/pty.c
+++ b/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)
-- 
2.24.1