Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1v8rT3-005tTT-QM for pgsql-general@arkaria.postgresql.org; Wed, 15 Oct 2025 02:42:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1v8rT2-004CFS-JX for pgsql-general@arkaria.postgresql.org; Wed, 15 Oct 2025 02:42:19 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1v8rT2-004CFJ-92 for pgsql-general@lists.postgresql.org; Wed, 15 Oct 2025 02:42:19 +0000 Received: from mail.cock.li ([37.120.193.124]) by makus.postgresql.org with smtp (Exim 4.96) (envelope-from ) id 1v8rSy-001opy-2B for pgsql-general@lists.postgresql.org; Wed, 15 Oct 2025 02:42:18 +0000 Date: Wed, 15 Oct 2025 02:42:01 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=airmail.cc; s=mail; t=1760496128; bh=7jYqU6YAr7sej2tWgKLKtuU/EQK+m7z6Rf6e5jc/xJo=; h=Date:From:To:CC:Subject:In-Reply-To:References:From; b=stALDV9XpmdLGdm3xlUQCHhh3UyHnEJrSsps3SgkUIK7gzCd4MhA9ftXKPfWhfe3b 91E/d5hPaLFRsqvu1QtqNVZAEJP0g4SpV/ymM5NwU0hJMFTbJDJZqQCZOvXGVOKdjn ZFIFdcTiYiw1MI5ibfPOf90xzY03ZPVNBawUDgwe4VWIQJcbSeo7nlM/adLqcgUt9t x3kT6DDNWtlXPTWJz43W2vSw168H5tCgUN+vbAyLzQs+jGUad8agAUcVHVr86uYr+v jE5rxUWmnv3yrDvTLcdOjobsRPH1f+OYfYpp1WaaS4cmaMcjR0XcR8SOANq4hBwFXw a+rwzLqoFx8SA== From: Bird To: pgsql-general@lists.postgresql.org, David Barsky , Ron Johnson CC: "pgsql-generallists.postgresql.org" Subject: =?US-ASCII?Q?Re=3A_Option_on_=60postgres=60_CLI_to_shutdown_?= =?US-ASCII?Q?when_there_are_no_more_active_connections=3F?= In-Reply-To: References: <73ff46d2-0bad-4a8d-9928-e494c2d5b0d1@gmail.com> <93702.1760321769@sss.pgh.pa.us> <233155.1760369829@sss.pgh.pa.us> Message-ID: <49F80E9B-C91F-4352-912B-DD39C84BBAD7@airmail.cc> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On October 14, 2025 9:40:45 PM UTC, David Barsky wr= ote: >> If testing is all scripted, then why not put "pg_ctl stop" at the end o= f >the script? > >Sorry for the delay=2E > >It=E2=80=99s _mostly_ scripted, but two major reasons: > >1=2E If that script is cancelled or interrupted for any reason, it=E2=80= =99s possible >that > `pg_ctl stop` won't be called and I'd have a leaked process=2E bash has EXIT trap you can use to run functions even in the case of interr= upts; You can create a wrapper script if its not written in bash=2E I could >mitigate > this by calling `pg_ctl stop` at the *start* of the script, but that >adds a > bit of latency I'd prefer to avoid=2E You could also run pg_ctl stop in the background (i=2Ee=2E in another proc= ess)=2E Again, if using bash, you just add & at the end=2E It should be pos= sible to create processes in any scripting language=2E