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 1r5uKa-00Fq9t-9B for pgsql-hackers@arkaria.postgresql.org; Wed, 22 Nov 2023 21:00: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 1r5uKY-00Cfqs-CJ for pgsql-hackers@arkaria.postgresql.org; Wed, 22 Nov 2023 21:00:18 +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 1r5uKX-00Cfqk-Uu for pgsql-hackers@lists.postgresql.org; Wed, 22 Nov 2023 21:00:18 +0000 Received: from meesny.iki.fi ([195.140.195.201]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r5uKT-006riq-4L for pgsql-hackers@postgresql.org; Wed, 22 Nov 2023 21:00:15 +0000 Received: from [192.168.1.115] (dsl-hkibng22-54f8db-125.dhcp.inet.fi [84.248.219.125]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: hlinnaka) by meesny.iki.fi (Postfix) with ESMTPSA id 4SbDCW2wdCzyPg; Wed, 22 Nov 2023 23:00:04 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=meesny; t=1700686808; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GPGoYb5ReTVzUJ7K6TiRWtCTxmRhSAvwa07uUe+L9vg=; b=EHWNebQYYGrsGHFiidNBhKMb2F90wPivEjv231yeFh3S/iqmaFMsZw/U7M7Zgnoax8c5dN edVW7X1dqBnlcHrqm9zHzlNaz2YaDab00J40e+/yforbHYb3QASjSXHMmFZJ0xDsBzU2th PKH1vx9PjV/MqHjke3mdA77IJkv8kY0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=meesny; t=1700686808; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GPGoYb5ReTVzUJ7K6TiRWtCTxmRhSAvwa07uUe+L9vg=; b=AR1/483Wi42d6o2GhgDUaKzggPYHISB9lmCpUbNYlSNmUrVCTNkmVk90RAr/svpMMSBxq3 Pt71MBEpFCcRb0KgWED+UO06iMhCvJzo+X1Z75JC8R2chfeDfiAqU4Ibp+27IykVNNmibl LpK98yZTpsYckZX+E96/F8AHsw7UsP0= ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=hlinnaka smtp.mailfrom=hlinnaka@iki.fi ARC-Seal: i=1; s=meesny; d=iki.fi; t=1700686808; a=rsa-sha256; cv=none; b=IDBN0xXUGjbyjwMwL4CIZSwIYB5tJe2Zo0AjspXP/tcs1SzPERamSTi41JxRSc0ej65PEq bFO5SYKS5yjTvQpUadNHx5CeFVrNEAn5/lQdrLyfkZqxdlOAjbe8ryhKufOhMVBZtRwCc0 C0tGZes36/kvUY76a0/SQuuUBQ6kwnw= Message-ID: <9b3693b7-0bc3-430a-b43f-eae44e8a39b6@iki.fi> Date: Wed, 22 Nov 2023 23:00:03 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: psql not responding to SIGINT upon db reconnection To: Tristan Partin Cc: Tom Lane , pgsql-hackers@postgresql.org, Shlok Kyal References: <1588058.1690220636@sss.pgh.pa.us> <5e28b89f-0033-4e42-8184-b71b731c1aa2@iki.fi> Content-Language: en-US From: Heikki Linnakangas In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 22/11/2023 19:29, Tristan Partin wrote: > On Thu Nov 16, 2023 at 8:33 AM CST, Heikki Linnakangas wrote: >> On 06/11/2023 19:16, Tristan Partin wrote: >>>>> That sounds like a much better solution. Attached you will find a v4 >>>>> that implements your suggestion. Please let me know if there is >>>>> something that I missed. I can confirm that the patch works. >> >> This patch is missing a select(). It will busy loop until the connection >> is established or cancelled. > > If I add a wait (select, poll, etc.), then I can't control-C during the > blocking call, so it doesn't really solve the problem. Hmm, they should return with EINTR on signal. At least on Linux; I'm not sure how portable that is. See signal(7) man page, section "Interruption of system calls and library functions by signal handlers". You could also use a timeout like 5 s to ensure that you wake up and notice that the signal was received eventually, even if it doesn't interrupt the blocking call. -- Heikki Linnakangas Neon (https://neon.tech)