X-Recipient: archive-cygwin@delorie.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:from:to:subject:date:message-id:references
	:in-reply-to:content-type:content-transfer-encoding
	:mime-version; q=dns; s=default; b=qxX/FPGnu4RaL7//DPGQW5CMlQLs6
	LYz5ZTE1ckJuk9BvVs1mhkRq67ySdIaC3/MkizAe8BwvnJoRpGwV9aVjs4UNV6+m
	O8bqjcKPL/45W5Ke0s47tdH0231xpKnTQaK5Opp7kL2sfO+0j9ebNE02W2KFS3cY
	XdtromDtHfZBcs=
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:from:to:subject:date:message-id:references
	:in-reply-to:content-type:content-transfer-encoding
	:mime-version; s=default; bh=vsoCyXc1RiVMQ4X5NxYeRAC+baY=; b=kgX
	Dy6VWrpmBmt5wibcMqpGHMJOgVtISjCTai0EvpqIYzEFlsmkBxJ6pNOWEwKd6rgP
	saPOBUUCfnpeyUI3UyvMk0FCpBFk1grm2nkYrN3yyc3sUcYvaenX9JX6q0n9L/rV
	eV2sRzOWrHFCBmmA+E4rcb3+XYbRaAEfyFxI9pnI=
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL,BAYES_00,MIME_BASE64_BLANKS,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2
X-HELO: nihxway2out.hub.nih.gov
X-IronPortListener: Outbound_SMTP
X-IronPort-Anti-Spam-Filtered: true
X-IronPort-Anti-Spam-Result: AgUGAEH6b1KcKEeq/2dsb2JhbABZgweBDIMTvCEYgRQWbQeCJQEBAQMBEhERSgsCAQgNDQIGCxUCAgIdExUCAQ0BAQQbGodfBp0wihySZoEpjF+BDjgKgmA1gQ0DjlOQGoNgh0WDJoFoQg
From: "Lavrentiev, Anton (NIH/NLM/NCBI) [C]" <lavr@ncbi.nlm.nih.gov>
To: "cygwin@cygwin.com" <cygwin@cygwin.com>
Subject: RE: fork() and NT error 0xC0000135 (STATUS_DLL_NOT_FOUND)
Date: Tue, 29 Oct 2013 18:13:15 +0000
Message-ID: <5F8AAC04F9616747BC4CC0E803D5907D0C40B088@MLBXv04.nih.gov>
References: <5F8AAC04F9616747BC4CC0E803D5907D0C40B026@MLBXv04.nih.gov> <526FED2A.20906@cygwin.com> <20131029172157.GA6342@calimero.vinschen.de>
In-Reply-To: <20131029172157.GA6342@calimero.vinschen.de>
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
X-IsSubscribed: yes
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from base64 to 8bit by delorie.com id r9TIDZao009058

> platforms expect /bin and/or /usr/bin to be in your path

I'm not following...  cygrunsrv.exe is started by Windows service controller,
and then spawns the server binary.  There's no point in this sequence of actions
to modify PATH.  I also believe, PATH is made compliant with what POSIX requirement
by that very cygwin1.dll implicitly (and that happens when cygrunsrv gets launched,
so cygwin1.dll figures out the CYGWIN "root" directory, then evaluates the path where
to expect all other CYGWIN dlls).  For cygrunsrv, the server binary is specified as an
absolute path with -p "/opt/path/to/bin/server.exe", which is within the rudimentary
CYGWIN tree that also has "/bin" (rooted at some Windows directory, C:\Apps\CYGWIN).

> Two points:
> 
> - cygrunsrv adds /bin to $PATH before calling the service executable.
> 
> - STATUS_DLL_NOT_FOUND does *not* imply that cygwin1.dll isn't found.
>   It could be any other DLL required by the executable but not in $PATH.
> 

Without chdir("/") fork() is able to succeed;  and the server binary does not
depend on any other non-Windows DLLs that are not in the "/bin" CYGWIN directory.

But with chdir("/") in place, if I insert (when manually simulating the very same
failure from a limited user account) "C:\Apps\CYGWIN\bin" into Windows PATH before
calling the server binary, it is able to fork successfully.  (Without the addition,
it fails same way with the same error 0xC00000135 even when run interactively.)

Anton Lavrentiev
Contractor NIH/NLM/NCBI


