From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 78868 invoked by alias); 4 Oct 2019 20:13:40 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 78861 invoked by uid 89); 4 Oct 2019 20:13:40 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.1 spammy=nonsense X-HELO: NAM04-SN1-obe.outbound.protection.outlook.com Received: from mail-eopbgr700096.outbound.protection.outlook.com (HELO NAM04-SN1-obe.outbound.protection.outlook.com) (40.107.70.96) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 04 Oct 2019 20:13:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dIqh3o8SauDoZITkBER8+Dp2YCzwUCQNNptRciECzmSaMOUpVWHup4eX3JdnawsCbUNFVY526YRKHAKgU/QW9SKJh4dA8spsNSP2JYf7fc/0gXC0d0swyAeuo9FQ7uTCLZzA7r/FZZjG+6pgMEJ1VONe/zhGfIzDaZ85xLWjSHfZ4pVoCIqVyqjBqmw4ZD6ECxTltmensqbKV0Pbm2rLqvjchFx+DoLs4235SPbn1sI25z2z1JvwLOmIMcu5V3+qMgF3gsSjX/gyE8hjLJ8yRvw3bPV0NfesKSbqcVoxKyKd5HB1vB2lwH9p4uk/D0cdpLuFMvUoOoQm3/cMB2r11g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=cTeoROhLTJNSMiknI8ur7+S5MZYfjz8iBQVTs5miYU0=; b=BmFygw9K+ImTq0Iqj3IhmJ6pfFbTz8M2VRQtKSxBiIRq9qliT1qma/YRoNLhbdAC31sd06Zf2asH6g7v/GecFSPq7xxyd6AenvwjWgh5Du/knj6sbIKTlXrfNNGtG6pr3/nAFLqaWRASzdx1q3S0iY04J5pVEPizkL8RLKzktAjIlPBKON9qXK6FiXZ3l/bZp+sZyavchDtPvHdYr5CQJ8CoJP4XtSuhrX+rJaxkgsOHQWCV/qGabgELQyBjXbo/izfhW/sIhOPyt9XudNvo4rrb980YkO1K993z1jZzQdIDNKG2/gL6Vtim98Lv01Pmme1IyMbZra8A4lv0B3CaTA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=cornell.edu; dmarc=pass action=none header.from=cornell.edu; dkim=pass header.d=cornell.edu; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cornell.edu; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=cTeoROhLTJNSMiknI8ur7+S5MZYfjz8iBQVTs5miYU0=; b=F1S0UbL2F7unJzwo6G5Mwuft2IHHx4fyz9PP46+dVTf6t8T/29Ms3+smMi0O/ywp+I5JhXscL3WVRjYtbUC2vBB7pcQtJHX+Y0kdLYPWU65BdygRoyu03iL5aU2k/LUTsqHcvpIn3Wi/M1wlmsofN0F1VkUfG3j5h29rgqnpLP8= Received: from DM6PR04MB5738.namprd04.prod.outlook.com (20.179.51.81) by DM6PR04MB4395.namprd04.prod.outlook.com (20.176.80.141) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2327.23; Fri, 4 Oct 2019 20:13:36 +0000 Received: from DM6PR04MB5738.namprd04.prod.outlook.com ([fe80::6998:197f:bcff:7172]) by DM6PR04MB5738.namprd04.prod.outlook.com ([fe80::6998:197f:bcff:7172%4]) with mapi id 15.20.2305.023; Fri, 4 Oct 2019 20:13:36 +0000 From: Ken Brown To: "cygwin@cygwin.com" Subject: Re: ssh-agent doesn't die Date: Fri, 04 Oct 2019 20:13:00 -0000 Message-ID: <81400f03-e424-255a-7b94-d3cbe584c356@cornell.edu> References: <319e26c0-32f0-40b7-2137-c7de170a3486@rl.ac.uk> <5b225738-c2d7-fbfe-48a7-8c2a38c3398c@cornell.edu> <0ccd17b6-c22a-1a18-9409-1ebcfae60868@huarp.harvard.edu> <9f7a14bb-f81b-c566-bb84-8da7fc6d0fad@cornell.edu> <185c5774-dd8b-5488-b818-4cec5a24bf2d@cornell.edu> <801bca17-2c61-bb6a-f02c-c4912232d9c5@cornell.edu> In-Reply-To: <801bca17-2c61-bb6a-f02c-c4912232d9c5@cornell.edu> user-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 authentication-results: spf=none (sender IP is ) smtp.mailfrom=kbrown@cornell.edu; x-ms-oob-tlc-oobclassifiers: OLM:9508; received-spf: None (protection.outlook.com: cornell.edu does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="Windows-1252" Content-ID: <67457FA75E85FA409971C675E05CD14B@namprd04.prod.outlook.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: nrHR6n1cQoQEh5nuU9/kF/ctunU7LK67O02ELq/rG5A4JXg6pQD9SKqk2t2MozpUifFegRYHStjgZnbno8QtkQ== X-IsSubscribed: yes X-SW-Source: 2019-10/txt/msg00024.txt.bz2 On 10/4/2019 10:27 AM, Ken Brown wrote: > On 9/29/2019 4:05 PM, Ken Brown wrote: >> On 9/27/2019 10:12 AM, Ken Brown wrote: >>> On 9/27/2019 9:37 AM, Norton Allen wrote: >>>> On 9/26/2019 10:50 PM, Ken Brown wrote: >>>>> >>>>>> As a simple test example, consider: >>>>>> >>>>>> /bin/ssh-agent /bin/sleep 10 >>>>>> >>>>>> While the sleep is still running, ps shows: >>>>>> >>>>>> =A0 =A0=A0=A0=A0=A0 PID=A0=A0=A0 PPID=A0=A0=A0 PGID=A0=A0=A0=A0 W= INPID=A0=A0 TTY=A0=A0=A0=A0=A0=A0=A0=A0 UID=A0=A0=A0 STIME COMMAND >>>>>> =A0 =A0=A0=A0=A0 1694=A0=A0=A0 1693=A0=A0=A0 1694=A0=A0=A0=A0=A0= =A0 1576=A0 ?=A0=A0=A0=A0=A0=A0=A0=A0=A0 22534 00:01:10 >>>>>> /usr/bin/ssh-agent >>>>>> =A0 =A0=A0=A0=A0 1653=A0=A0=A0=A0=A0=A0 1=A0=A0=A0 1653=A0=A0=A0= =A0=A0 11740=A0 cons1=A0=A0=A0=A0=A0 22534 00:00:37 /usr/bin/bash >>>>>> =A0 =A0=A0=A0=A0 1693=A0=A0=A0 1653=A0=A0=A0 1693=A0=A0=A0=A0=A0= =A0 1552=A0 cons1=A0=A0=A0=A0=A0 22534 00:01:10 /usr/bin/sleep >>>>>> >>>>>> One oddity is that ssh-agent is listed as a subprocess of sleep >>>>> ...but this isn't a bug.=A0 ssh-agent forks, and then the parent exec= s the command. >>>> >>>> With the salient difference presumably being that the exec is done in = the parent >>>> instead of the child as usual? >>> >>> Yes. The idea is that 'ssh-agent command' should be more-or-less equiv= alent to >>> running 'command', with ssh-agent running as a subprocess. >>> >>> The ssh-agent subprocess periodically checks to see if its parent is st= ill >>> alive, and it exits when the parent has died. Someone should figure ou= t why >>> this is not working on Cygwin. >> >> As an aid to someone who might want to debug this (probably Corinna when= she >> returns), I've created a test program agent.c (attached) that simulates = the >> relevant part of ssh-agent: >> >> 1. It forks a subprocess that periodically checks to see if its parent h= as died, >> and then exits. >> >> 2. The parent execs "/usr/bin/sleep 1". >> >> As with ssh-agent, the subprocess never detects that the parent has died= , and so >> it never exits. >> >> Running this program under strace shows the following error in the pinfo >> constructor: >> >> pinfo::pinfo: couldn't duplicate parent rd_proc_pipe handle 0x1BC for fo= rked >> child 1666 after exec, Win32 error 5 >> >> [Win32 error 5 is ERROR_ACCESS_DENIED.] >=20 > It seems that the pinfo constructor failure happens in > cygheap_exec_info::reattach_children(). The latter is preceded by the fo= llowing > comment: >=20 > /* Reattach non-reaped subprocesses passed in from the cygwin process > which previously operated under this pid. FIXME: Is there a race he= re > if the process exits during cygwin's exec handoff? */ >=20 > I tried running my test program under gdb with a breakpoint at > reattach_children, and the breakpoint was never hit. That gives an affir= mative > answer to the question in the FIXME. > > As a result, the exec'd program never becomes aware that it has a subproc= ess, so > it exits without resetting the subprocess's ppid to 1. >=20 > Is there someone out there familiar enough with Cygwin's exec to suggest = a fix? > It would be a nice gift to Corinna to get this fixed before her return. What I said above about gdb is nonsense. It's the exec'd process that call= s=20 reattach_children, so I wouldn't expect gdb to see that call. I think the = rest=20 of my analysis is correct, but I'm not sure that the FIXME explains the fai= lure. Ken -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple