From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id 2B3763861838; Tue, 11 Aug 2020 10:20:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2B3763861838 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Corinna Vinschen To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: pty: Add a workaround for issue of starting a lot of mintty. X-Act-Checkin: newlib-cygwin X-Git-Author: Takashi Yano X-Git-Refname: refs/heads/master X-Git-Oldrev: a44bc679a47403e5439ae46106a886fcb6240233 X-Git-Newrev: f14d123ac62cfa93ef959154cf80bbced6c76958 Message-Id: <20200811102016.2B3763861838@sourceware.org> Date: Tue, 11 Aug 2020 10:20:16 +0000 (GMT) X-BeenThere: cygwin-cvs@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Cygwin core component git logs List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Aug 2020 10:20:16 -0000 https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=f14d123ac62cfa93ef959154cf80bbced6c76958 commit f14d123ac62cfa93ef959154cf80bbced6c76958 Author: Takashi Yano Date: Tue Aug 11 13:16:52 2020 +0900 Cygwin: pty: Add a workaround for issue of starting a lot of mintty. - If a lot of mintty are started in a short time from a mintty, some of them hang with empty screen, crash immediately or hang on exiting mintty. The following report seems to be related to this issue. https://cygwin.com/pipermail/cygwin/2020-August/245751.html The cause is not clear at all, but this patch seems to solve the issue. Diff: --- winsup/cygwin/spawn.cc | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc index 840ec4a86..e70ceb86d 100644 --- a/winsup/cygwin/spawn.cc +++ b/winsup/cygwin/spawn.cc @@ -177,7 +177,7 @@ find_exec (const char *name, path_conv& buf, const char *search, /* Utility for child_info_spawn::worker. */ static HANDLE -handle (int fd, bool writing) +handle (int fd, bool writing, bool iscygwin) { HANDLE h; cygheap_fdget cfd (fd); @@ -188,6 +188,11 @@ handle (int fd, bool writing) h = INVALID_HANDLE_VALUE; else if (!writing) h = cfd->get_handle (); + else if (cfd->get_major () == DEV_PTYS_MAJOR && iscygwin) + { + fhandler_pty_slave *ptys = (fhandler_pty_slave *)(fhandler_base *) cfd; + h = ptys->get_output_handle_cyg (); + } else h = cfd->get_output_handle (); @@ -625,9 +630,11 @@ child_info_spawn::worker (const char *prog_arg, const char *const *argv, /* Set up needed handles for stdio */ si.dwFlags = STARTF_USESTDHANDLES; - si.hStdInput = handle ((in__stdin < 0 ? 0 : in__stdin), false); - si.hStdOutput = handle ((in__stdout < 0 ? 1 : in__stdout), true); - si.hStdError = handle (2, true); + si.hStdInput = handle ((in__stdin < 0 ? 0 : in__stdin), false, + iscygwin ()); + si.hStdOutput = handle ((in__stdout < 0 ? 1 : in__stdout), true, + iscygwin ()); + si.hStdError = handle (2, true, iscygwin ()); si.cb = sizeof (si);