Re: Don't use the deprecated and insecure PQcancel in our frontend tools anymore
Jelte Fennema-Nio <postgres@jeltef.nl>
From: "Jelte Fennema-Nio" <postgres@jeltef.nl>
To: "Heikki Linnakangas" <hlinnaka@iki.fi>
Cc: "PostgreSQL Hackers" <pgsql-hackers@lists.postgresql.org>, "Alvaro
Herrera" <alvherre@alvh.no-ip.org>, "Jacob Champion"
<jacob.champion@enterprisedb.com>
Date: 2026-07-07T07:54:09Z
Lists: pgsql-hackers
Attachments
- v9-0001-psql-Replace-cancel_pressed-with-CancelRequested.patch (text/x-patch) patch v9-0001
- v9-0002-fe_utils-Simplify-cancel-logic-in-wait_on_slots.patch (text/x-patch) patch v9-0002
- v9-0003-Move-Windows-pthread-compatibility-functions-to-s.patch (text/x-patch) patch v9-0003
- v9-0004-Don-t-use-deprecated-and-insecure-PQcancel-psql-a.patch (text/x-patch) patch v9-0004
On Tue Jul 7, 2026 at 12:12 AM CEST, Heikki Linnakangas wrote: > This relies on the signal to interrupt select(), but I'm afraid that's > not guaranteed on all platforms. Also, there's a race condition if the > signal arrives *just* before you call select(). That's what the > "self-pipe hack" is for, see comments at waiteventset.c. Ugh yes you're right. The comment above that block told me otherwise and I didn't question it. Attached is a new version that improves the comment and starts using the same 1 second poll on all platforms.