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 1tad7I-003dSV-HT for pgsql-hackers@arkaria.postgresql.org; Wed, 22 Jan 2025 15:58:09 +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 1tad7H-001Ojs-JP for pgsql-hackers@arkaria.postgresql.org; Wed, 22 Jan 2025 15:58:07 +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 1tad7H-001Ojk-6A for pgsql-hackers@lists.postgresql.org; Wed, 22 Jan 2025 15:58:07 +0000 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tad7E-000vwK-2R for pgsql-hackers@postgresql.org; Wed, 22 Jan 2025 15:58:06 +0000 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-2163dc5155fso135613645ad.0 for ; Wed, 22 Jan 2025 07:58:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cleverelephant-ca.20230601.gappssmtp.com; s=20230601; t=1737561484; x=1738166284; darn=postgresql.org; h=to:cc:date:message-id:subject:mime-version:from:from:to:cc:subject :date:message-id:reply-to; bh=Qu6bTYI1EcWPVOksS8lVxKwjdiZ2/ryXHZfZh+p5fGQ=; b=16RR5jwQ8J3+XRWot+OXPVoEtN4rO2eR5vTNpw35XUn/0F9gFdJfh9IVEZEDik3iaH dt923jK9yfSiTymwvkqQsTYNH8l2XaitfM7U8ht6ind3VQiGOaPoIvLj1F5Nc9hXi/m7 WUubZ24Q9QH4Xpwlxb4EvZJjilf+oNJRegPjQteo7YqluxLSPcbY7NnSabOWYxoaCP/C Kg6DywgdwM9bpJpjlOHGRLUF6wLCGwYiyW6t+nw/Xh4ze3LcZjUxsuPH3aX1sftR6oi5 hZqEkhzVm0LqWxY195Q7OXj/Fsm1AKDl2mhW13WFWNjdO5LXUteB0JcrO2VKONGq5IDy sbOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737561484; x=1738166284; h=to:cc:date:message-id:subject:mime-version:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=Qu6bTYI1EcWPVOksS8lVxKwjdiZ2/ryXHZfZh+p5fGQ=; b=DXXprLEZZXwzwl60bj0hHLC/0aJwCbycgMu8mIa0AAbTGrQyNSNLecbSBYn51SlHtA vdStWP/LUGXf2yr0fkfjIR2NlLYzOpTIjEL27UziAPbeBHwGLMjl4GAiufDTuSxJn+Eg AnYzM2gl49lpTDrjovYFI677Ip2D6L3gneckwXd0FZuufYTh9yJpmVQNVQX3AjyhaEoT 4VCIX+17J5Mz9vhVaJ3VhKxKkn30P5efcpubnSOP5eiZxdMuIlidcviuCP+tiyxSwsW3 +a66y5F4qKXUjX9LZtbp0QNJGlsrpsNXgrBzsXas08YkvRh2acA87hk5pkpcENWYbWPM icJA== X-Gm-Message-State: AOJu0Yzrhp771cS6ky7+LtO3jcT1N4IAKBUq6/0CQWiHSqPa17pIv8bk 1KUmkL9bvIoGEGmUyd+/HlgNYUdrn7jLMZ9HuDmFwvJhJjsVQxsSlkf8THFP4kpvaDfIqh9wLss = X-Gm-Gg: ASbGnctHbMHRrH1GhHnpyASJeNksHGQfSGMxq0ISz4zGCuAvIkw1V6vWubUo8jYOAB+ /68pzuBHULwO2HpzXc3ZuO3csNdcNJubt3kz9LOjf4kWQ5c8WN3TQq9SqBNO6q1EO2LBt88LIOt r+rIe+t7/lUBJWsU/9dmtIo3khdAnKsy1zmvcYhzz/gFswRYRjXrfSkigEFcOx6kgjzQtr2x2lj OYyBk8DMpmrRkOeCNHcw8DJQLSHwQgIoNdQkv/+pPSGNLjeeAJlO02m2G0w+SLHcXF0QfrTq23h nYJUT5UXtqk0YqjT8V7pkolhPFA4jMNrUP36lMlSmA/Eq6O7BBWH/hY= X-Google-Smtp-Source: AGHT+IEDMjVQqaT4r4Or3qETmATR+Kt8I/83H1N7O0eTzz0DpoLIalmZPnKTIU/XM2ap8XPffdueDg== X-Received: by 2002:a05:6a21:998d:b0:1e1:b28e:a148 with SMTP id adf61e73a8af0-1eb2144d513mr29181751637.5.1737561483798; Wed, 22 Jan 2025 07:58:03 -0800 (PST) Received: from smtpclient.apple (S010600ab48f52a80.gv.shawcable.net. [24.69.185.101]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72dab9b9ad5sm11621844b3a.96.2025.01.22.07.58.03 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Jan 2025 07:58:03 -0800 (PST) From: Paul Ramsey Content-Type: multipart/alternative; boundary="Apple-Mail=_BEC8EF84-7969-4B3C-806C-4BB8E32A3DC2" Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3776.700.51.11.1\)) Subject: Converting pqsignal to void return Message-Id: <4E796D56-79B5-4447-9DA7-5428BC1A6B53@cleverelephant.ca> Date: Wed, 22 Jan 2025 07:57:52 -0800 Cc: Nathan Bossart To: PostgreSQL Hackers X-Mailer: Apple Mail (2.3776.700.51.11.1) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Apple-Mail=_BEC8EF84-7969-4B3C-806C-4BB8E32A3DC2 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Nathan,=20 I just ran across this change when a bunch of CI=E2=80=99s I run barfed.=20= = https://github.com/postgres/postgres/commit/d4a43b283751b23d32bbfa1ecc2cad= 2d16e3dde9 The problem we are having in extension land is that we often run = functions in external libraries that take a long time to return, and we = would like to ensure that PgSQL users can cancel their queries, even = when control has passed into those functions. The way we have done it, historically, has been to take the return value = of pqsignal(SIGINT, extension_signint_handler) and remember it, and = then, inside extension_signint_handler, call the pgsql handler once we = have done our own business.=20 https://github.com/pramsey/pgsql-http/blob/master/http.c#L345 It is possible we have been Doing It Wrong all this time, and would love = some pointers on the right way to do this. Alternatively, if we have a valid use case, it would be nice to have the = return value from pqsignal() back. Thanks! Paul=20= --Apple-Mail=_BEC8EF84-7969-4B3C-806C-4BB8E32A3DC2 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 Nathan, 

I just ran across = this change when a bunch of CI=E2=80=99s I run = barfed. 


The problem = we are having in extension land is that we often run functions in = external libraries that take a long time to return, and we would like to = ensure that PgSQL users can cancel their queries, even when control has = passed into those functions.

The way we have = done it, historically, has been to take the return value of = pqsignal(SIGINT, extension_signint_handler) and remember it, and then, = inside extension_signint_handler, call the pgsql handler once we have = done our own business. 

<= br>
It is possible we have been Doing It Wrong all this time, = and would love some pointers on the right way to do = this.

Alternatively, if we have a valid use = case, it would be nice to have the return value from pqsignal() = back.

Thanks!

Paul =
= --Apple-Mail=_BEC8EF84-7969-4B3C-806C-4BB8E32A3DC2--