Re: In MacOS, psql reacts on SIGINT in a strange fashion (Linux is fine) - Mailing list pgsql-hackers

From Tom Lane
Subject Re: In MacOS, psql reacts on SIGINT in a strange fashion (Linux is fine)
Date
Msg-id 271520.1713052173@sss.pgh.pa.us
Whole thread Raw
In response to Re: In MacOS, psql reacts on SIGINT in a strange fashion (Linux is fine)  (Dmitry Koterov <dmitry.koterov@gmail.com>)
Responses Re: In MacOS, psql reacts on SIGINT in a strange fashion (Linux is fine)
Re: In MacOS, psql reacts on SIGINT in a strange fashion (Linux is fine)
List pgsql-hackers
Dmitry Koterov <dmitry.koterov@gmail.com> writes:
> I wish it was zsh... I tested it with zsh, but with bash (and with
> low-level kill syscall), I observed the same effect unfortunately.

> So it's still a puzzle.

> 1. Even more, when I send a kill() low-level syscall using e.g. Perl - perl
> -e 'kill("INT", 16107)' - it is the same.
> 2. If any other program but psql is used (e.g. vim or my custom Perl script
> which ignores SIGINT), the effect is not reproducible.

> Can it be e.g. readline? Or something related to tty or session settings
> which psql could modify (I did not find any in the source code though).

OK, I tried dtruss'ing psql on macOS.  What I see is that with
Apple's libedit, the response to SIGINT includes this:

kill(0, 2)               = 0 0

that is, "SIGINT my whole process group".  If I build with libreadline
from MacPorts, I just see

kill(30902, 2)           = 0 0

(30902 being the process's own PID).  I'm not real sure why either
library finds it necessary to re-signal the process --- maybe they
trap SIGINT and then try to hide that by reinstalling the app's
normal SIGINT handler and re-delivering the signal.  But anyway,
libedit seems to be vastly exceeding its authority here.  If
signaling the whole process group were wanted, it would have been
the responsibility of the original signaller to do that.

            regards, tom lane



pgsql-hackers by date:

Previous
From: Thomas Munro
Date:
Subject: Re: In MacOS, psql reacts on SIGINT in a strange fashion (Linux is fine)
Next
From: Thomas Munro
Date:
Subject: Re: In MacOS, psql reacts on SIGINT in a strange fashion (Linux is fine)