delorie.com/archives/browse.cgi | search |
X-Recipient: | archive-cygwin AT delorie DOT com |
DomainKey-Signature: | a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id |
:list-unsubscribe:list-subscribe:list-archive:list-post | |
:list-help:sender:date:from:to:subject:message-id:reply-to | |
:references:mime-version:content-type:in-reply-to; q=dns; s= | |
default; b=XnX8UFwTXZryvDQPHJ3fkPl7QfdVcQKHLjqmN6P0O/lMEjbV018/6 | |
y6C9+4RiOD2A6hcdqA9IRzF4czszzegWQfF3ngN1LoEJBm85Z2sNT0+lcNa2np95 | |
HEYO2XoWRXmiREpKcXEA+vXZ+5/fKBY88PVHm7ZO1U6NdXs6FcRn2Q= | |
DKIM-Signature: | v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id |
:list-unsubscribe:list-subscribe:list-archive:list-post | |
:list-help:sender:date:from:to:subject:message-id:reply-to | |
:references:mime-version:content-type:in-reply-to; s=default; | |
bh=jZVvWXBQNnsXS3uizgezJOUKqcg=; b=GDMfnuLLNki7ENE0y/KZUbsGcO/w | |
Q3sszopG552lJBs67sOBrwE4i0kPe0+VpItuOp1AP0907A6fP/lCZauymMZ5fp0X | |
yjAvfgX1cHD3JQCc6qHapz3oOfYXShW1jbhsCQJTqUM6rVP7l1uHW8AfG/rCSrlY | |
fk54XDSme3H9S50= | |
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
List-Id: | <cygwin.cygwin.com> |
List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
List-Archive: | <http://sourceware.org/ml/cygwin/> |
List-Post: | <mailto:cygwin AT cygwin DOT com> |
List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> |
Sender: | cygwin-owner AT cygwin DOT com |
Mail-Followup-To: | cygwin AT cygwin DOT com |
Delivered-To: | mailing list cygwin AT cygwin DOT com |
Authentication-Results: | sourceware.org; auth=none |
X-Virus-Found: | No |
X-Spam-SWARE-Status: | No, score=-4.1 required=5.0 tests=AWL,BAYES_50,KAM_LAZY_DOMAIN_SECURITY autolearn=no version=3.3.2 |
X-HELO: | calimero.vinschen.de |
Date: | Wed, 27 May 2015 14:23:12 +0200 |
From: | Corinna Vinschen <corinna-cygwin AT cygwin DOT com> |
To: | cygwin AT cygwin DOT com |
Subject: | Re: cygwin-2 process handling |
Message-ID: | <20150527122312.GF16927@calimero.vinschen.de> |
Reply-To: | cygwin AT cygwin DOT com |
Mail-Followup-To: | cygwin AT cygwin DOT com |
References: | <1573487218 DOT 1490468 DOT 1431969356192 DOT JavaMail DOT yahoo AT mail DOT yahoo DOT com> <555B6F71 DOT 4040906 AT cornell DOT edu> <555B7E03 DOT 40404 AT cornell DOT edu> <20150521205357 DOT 2c125b3bcaf877d0843b52b1 AT nifty DOT ne DOT jp> |
MIME-Version: | 1.0 |
In-Reply-To: | <20150521205357.2c125b3bcaf877d0843b52b1@nifty.ne.jp> |
User-Agent: | Mutt/1.5.23 (2014-03-12) |
--eNMatiwYGLtwo1cJ Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi Takashi, On May 21 20:53, Takashi Yano wrote: > [...] > I was looking into this problem, and found the PeekNamedPipe() > call is blocked in fhandler_pty_master::close() when the problem > occurs. >=20 > I had not noticed that,=20 >=20 > https://msdn.microsoft.com/en-us/library/windows/desktop/aa365779(v=3Dvs.= 85).aspx >=20 > says: > > The PeekNamedPipe function can block thread execution the same > > way any I/O function can when called on a synchronous handle in > > a multi-threaded application. >=20 > I have made a patch attached to resolve this problem. Please have > a look. >=20 > With this patch, NtQueryObject() is used instead of PeekNamedPipe() > to detect closure of the last master handle. >=20 > Please refer to the following discussion for more details. > http://cygwin.com/ml/cygwin/2015-03/msg00221.html >=20 >=20 > ChageLog is as follows. >=20 > 2015-05-21 Takashi Yano <...> >=20 > * fhandler_tty.cc (fhandler_pty_master::close): Use NtQueryObject() > instead of PeekNamedPipe() to detect closing the last master handle. > [...] > + if (output_handle_local) > + { > + OBJECT_BASIC_INFORMATION obi; > + NTSTATUS status; > + ULONG hdl_cnt =3D 0; > + > + status =3D NtQueryObject (output_handle_local, ObjectBasicInformat= ion, > + &obi, sizeof obi, NULL); > + if (!NT_SUCCESS (status)) > + debug_printf ("NtQueryObject: %y", status); > + else > + hdl_cnt =3D obi.HandleCount; > + termios_printf("HandleCount: %d", hdl_cnt); > + if (hdl_cnt =3D=3D 1) > + SetEvent (input_available_event); > + CloseHandle (output_handle_local); > + } =20 Isn't that racy? Consider two processes doing that at the same time. Both calls to NtQueryObject could come up with hdl_cnt =3D=3D 2 and the problem persists. Wouldn't it be safer to call SetEvent(input_available_event) all the time from here? Corinna --=20 Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Maintainer cygwin AT cygwin DOT com Red Hat --eNMatiwYGLtwo1cJ Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJVZbcwAAoJEPU2Bp2uRE+gb6YP/3AKtY7kYmlj0aVlmrV1odZv NpxE0B+KFXl0Nlv6e3lm62+XgETaQCI9HorA00cIDL8gewjcmEchXuZ6e5AaFCnR lHou77HUz/QrcsDthWetU/pTuoD5dVDYYaIlL9JqlMkqHmUkifuLoUyOZcnMjYdl HPJrqGlGpQQXlMtxCxDSmN8H1U7Jwu6XD2YygAt42zdiXYjd0hEl/P5xa9jid1rO KjQTy00MXtPh29XCb1pgUSqmyEdG9lBLFz+O+71+8uPXWqXAtLYpubsSM1XvtbhN tuj2to6lNM1YxZrP/WFpVpTfBfmkyIGRRVSIwNbL+7WQosuTYSpVkc8sqHTUGlDm vMDLYc2Wkudihz8mCBt9sPr2Zw05kFZeaj72h2ZHbqoEE3TyHX7mtIU4Tyq1euKu i1QbpelkkCfpMPpxvC0TVvYq92WX/fHgZ2WwhmaIFCd1tNucf7EULCfXq3WUtmyG Uq4iEWb2leTRPYYM5bEMwxuvW4cK89QYjbD9e5q7brH6/vcqHj2HNxov4T5y2A9i Rb2yVnTOz+3NrqslDZi99gZ9x4FWuw5u1Y48c2AoSXbL9M7IzJJRme1IL7/SuiAC 1piF8eC2HLGkCS6BuZtn+ytuThG1MTLRN5xqqxENwCMoBZ4CLvP1DtTZ9yLP/Wb3 NoVewy5Q3GwFgXMtK9W4 =JHk5 -----END PGP SIGNATURE----- --eNMatiwYGLtwo1cJ--
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |