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 1mlCiT-0008Oa-6w for pgsql-hackers@arkaria.postgresql.org; Thu, 11 Nov 2021 16:14:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mlCiS-0005d7-76 for pgsql-hackers@arkaria.postgresql.org; Thu, 11 Nov 2021 16:14:20 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mlCg9-0001HN-4T for pgsql-hackers@lists.postgresql.org; Thu, 11 Nov 2021 16:11:57 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mlCg7-0003Ej-2z for pgsql-hackers@lists.postgresql.org; Thu, 11 Nov 2021 16:11:56 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 1ABGBpvB1553330; Thu, 11 Nov 2021 11:11:51 -0500 From: Tom Lane To: "Bossart, Nathan" cc: "pgsql-hackers@lists.postgresql.org" Subject: Re: Improving psql's \password command In-reply-to: <7BAC8A28-148B-4B03-A345-D68071388300@amazon.com> References: <747443.1635536754@sss.pgh.pa.us> <765509.1635552418@sss.pgh.pa.us> <7BAC8A28-148B-4B03-A345-D68071388300@amazon.com> Comments: In-reply-to "Bossart, Nathan" message dated "Thu, 11 Nov 2021 16:04:02 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1553328.1636647111.1@sss.pgh.pa.us> Date: Thu, 11 Nov 2021 11:11:51 -0500 Message-ID: <1553329.1636647111@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk "Bossart, Nathan" writes: > On 10/29/21, 5:07 PM, "Tom Lane" wrote: >> I was afraid somebody would say that. I have looked at it, but AFAICS >> we'd have to duplicate all of sprompt.c and nearly all of pg_get_line.c >> in order to tie it into psql's SIGINT infrastructure, since we wouldn't >> dare enable the signal handler except during the innermost fgets() call, >> and if we did get a signal we'd still need to clean up the terminal echo >> state, so we couldn't just longjmp out of simple_prompt(). The >> cost/benefit ratio of that doesn't look very good. > Hm. Is it really necessary to duplicate all of sprompt.c and > pg_get_line.c? Would it be possible to teach the existing functions > how to optionally enable SIGINT handling instead? I wouldn't mind > trying my hand at this if it seems like a reasonable approach. It seems to me it'd overcomplicate simple_prompt's API for one use-case ... but if you want to try it, step right up. (I suppose some of that objection could be overcome by making simple_prompt into a wrapper around another function not_so_simple_prompt.) regards, tom lane