Skip to content

Commit 00e7a89

Browse files
committed
Cygwin: pty: Return EMFILE when too meny ptmx are opened
Previously, opening /dev/ptmx fails without setting errno when it is opened too many times. With this patch, return EMFILE in that situation. Addresses: https://cygwin.com/pipermail/cygwin/2025-March/257786.html Fixes: 09738c3 ("Cygwin: pty: setup new pty on opening the master, not in constructor") Reported-by: Christian Franke <[email protected]> Signed-off-by: Takashi Yano <[email protected]> (cherry picked from commit 7fc7d8b)
1 parent 05387dd commit 00e7a89

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

winsup/cygwin/fhandler/pty.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1933,7 +1933,10 @@ int
19331933
fhandler_pty_master::open (int flags, mode_t)
19341934
{
19351935
if (!setup ())
1936+
{
1937+
set_errno (EMFILE);
19361938
return 0;
1939+
}
19371940
set_open_status ();
19381941
dwProcessId = GetCurrentProcessId ();
19391942
return 1;

winsup/cygwin/release/3.6.1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,6 @@ Fixes:
2727
- Accommodate a change in Windows exception handling affecting software
2828
generated exceptions.
2929
Addresses: https://cygwin.com/pipermail/cygwin/2025-March/257808.html
30+
31+
- Return EMFILE when opening /dev/ptmx too many times.
32+
Addresses: https://cygwin.com/pipermail/cygwin/2025-March/257786.html

winsup/cygwin/tty.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ tty_list::allocate (HANDLE& r, HANDLE& w)
147147
termios_printf ("pty%d allocated", freetty);
148148
else
149149
{
150-
system_printf ("No pty allocated");
150+
termios_printf ("No pty allocated");
151151
r = w = NULL;
152152
}
153153

0 commit comments

Comments
 (0)