Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lIFeF-00089e-NE for pgsql-hackers@arkaria.postgresql.org; Fri, 05 Mar 2021 18:58:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lIFeE-0001hU-Jz for pgsql-hackers@arkaria.postgresql.org; Fri, 05 Mar 2021 18:58:02 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lIFeD-0001hN-KR for pgsql-hackers@lists.postgresql.org; Fri, 05 Mar 2021 18:58:02 +0000 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lIFeA-0001EH-C2 for pgsql-hackers@postgresql.org; Fri, 05 Mar 2021 18:58:00 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 4FC5A2AE5; Fri, 5 Mar 2021 13:57:56 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Fri, 05 Mar 2021 13:57:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm1; bh=LgfsVtTT8yU/YtTeIZcq5mxEmri mqY01SZG7jouEfQs=; b=JkjCAYZxHWO5MkhcAOj7XOITpe4M9R4oe4sJDzXmARc FwR9YCFILUhVzgYQ6SR4IcAWUD6X1o15Dcu+H2VnqvqLmKWhAD4dlmTaKkpSj1mV NAn68z3o6GK0BEwNLBGEKwCiQ3QK1mhlvcmtQ2quGM0CxM084gu/t0uxKf+vIBCx OqilEMQ1HraIeB2wangw4RQs2YLC9G8lRGAv8G4YFy5cSO4efgEcBnNgDjGTJ/K3 AptfohlDFHtCJOYsnpwh4DyNh0hX2wIrfRSPZwlvesV5KRLyDLsXPYLR8rfckb/a UCfvH0eqENnlNJRlpTSXYFxl4VaHC1rr+W0BcXeMqYA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=LgfsVt TT8yU/YtTeIZcq5mxEmrimqY01SZG7jouEfQs=; b=iLvFr9NmZX+uDzZQ+eHSaD nGSzxy/WcfdJDiiA56O1j/fc+QyT2Jcpykhr+mPQQcZd84RsFRX6rCBCfs39mZhX P01MqUeCclPWsFIeg4oYPMu6TZucYn9ebLihJHCtbpaqw/PwfhNCqHilfwY8ycrp iKsT/xvKyY2s9l53SFX+oxlOLtW9HmVxQMX+b1AuHj4yuxlNuN4+/hiP6j5Y4XYo SUMQw6qtL3L0BtNvzDfnxIFAflv3iZkzAyhB8CuCQHNcxG4t5qi4Bw6UJcYBvVU3 Q1kc4MuFjLB2TVcY5lfgMe8IfZTgbG9DWr18v++26W393n0Qk+4ymst8m38gkkNg == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledruddtiedguddtlecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpeffhffvuffkfhggtggujgesthdtredttddtvdenucfhrhhomheptehnughr vghsucfhrhgvuhhnugcuoegrnhgurhgvshesrghnrghrrgiivghlrdguvgeqnecuggftrf grthhtvghrnhepudekhfekleeugeevteehleffffejgeelueduleeffeeutdelffeujeff hfeuffdunecukfhppeeijedrudeitddrvddujedrvdehtdenucevlhhushhtvghrufhiii gvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrnhgurhgvshesrghnrghrrgiivghl rdguvg X-ME-Proxy: Received: from intern.anarazel.de (c-67-160-217-250.hsd1.ca.comcast.net [67.160.217.250]) by mail.messagingengine.com (Postfix) with ESMTPA id 6882A240057; Fri, 5 Mar 2021 13:57:54 -0500 (EST) Date: Fri, 5 Mar 2021 10:57:52 -0800 From: Andres Freund To: Magnus Hagander , Alvaro Herrera , Michael Paquier Cc: Dave Page , Andrew Dunstan , PostgreSQL-development , Thomas Munro , Heikki Linnakangas Subject: Re: CI/windows docker vs "am a service" autodetection on windows Message-ID: <20210305185752.3up5eq2eanb7ofmb@alap3.anarazel.de> References: <20210304190817.at3r2kedvm5e3rq7@alap3.anarazel.de> <58c9854f-fa1c-e5df-3b8e-0c36a912c836@dunslane.net> <20210304203008.zy3op3fisra5tlun@alap3.anarazel.de> <20210304204859.65z6ynqicmlobi7r@alap3.anarazel.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210304204859.65z6ynqicmlobi7r@alap3.anarazel.de> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On 2021-03-04 12:48:59 -0800, Andres Freund wrote: > On 2021-03-04 21:36:23 +0100, Magnus Hagander wrote: > > > I think that's a good answer for pg_ctl - not so sure about postgres > > > itself, at least once it's up and running. I don't know what lead to all > > > of this autodetection stuff, but is there the possibility of blocking on > > > whatever stderr is set too as a service? > > > > > > Perhaps we could make the service detection more reliable by checking > > > whether stderr is actually something useful? > > > > So IIRC, and mind that this is like 15 years ago, there is something > > that looks like stderr, but the contents are thrown away. It probably > > exists specifically so that programs won't crash when run as a > > service... > > Yea, that'd make sense. > > I wish we had tests for the service stuff, but that's from long before > there were tap tests... After fighting with a windows VM for a bit (ugh), it turns out that yes, there is stderr, but that fileno(stderr) returns -2, and GetStdHandle(STD_ERROR_HANDLE) returns NULL (not INVALID_HANDLE_VALUE). The complexity however is that while that's true for pg_ctl within pgwin32_ServiceMain: checking what stderr=00007FF8687DFCB0 is (handle: 0, fileno=-2) but not for postmaster or backends WARNING: 01000: checking what stderr=00007FF880F5FCB0 is (handle: 92, fileno=2) which makes sense in a way, because we don't tell CreateProcessAsUser() that it should pass stdin/out/err down (which then seems to magically get access to the "topmost" console applications output - damn, this stuff is weird). You'd earlier mentioned that other distributions may not use pg_ctl register - but I assume they use pg_ctl runservice? Or do they actually re-implement all those magic incantations in pg_ctl.c? Greetings, Andres Freund