Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command

From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: 趙明春 <mzhao(at)insight-tec(dot)co(dot)jp>, Michael Paquier <michael(at)paquier(dot)xyz>, "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, "pgsql-bugs(at)lists(dot)postgresql(dot)org" <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command
Date: 2018-02-22 19:35:08
Message-ID: CABUevEw0Za=f0fDHKBE26fj5Qhbo0fzWyhf8FDe-8qtD3QPU7Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Thu, Feb 22, 2018 at 4:12 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> =?UTF-8?B?6LaZ5piO5pil?= <mzhao(at)insight-tec(dot)co(dot)jp> writes:
> > So, Let me change my question:
> > If I started the PostgreSQL by pg_ctl command in the same Windows command
> > prompt,
> > Is it possible that pressing Ctrl + C on psql to break query(not session)
> > will send SIGINT to postmaster process unexpectedly?
>
> I don't know much about Windows signal processing, but the log entries you
> show certainly look like that's what happened.
>

Yes, this is unfortunately exactly how it works on Windows.

There is on way to intercept the Ctrl-C and have it not delivered to *all*
processes out of the same session. It can only be added or removed for the
current process (which psql does). So it gets delivered to the backends
which call pg_console_handler, which emulates SIGINT.

On Unix-ish machines it's normal for control-C to send a SIGINT to every
> process that's in the terminal's process group --- *not* just the
> foreground process. So if you launch the postmaster manually you'd better
> make sure that it gets dissociated from the terminal, or you're at risk
> of killing it accidentally. (Or, if you want to leave it connected to
> that terminal, you use another window to run psql etc.) It seems that
> something similar is happening on your Windows setup. I don't know
> the rules for process/terminal association on Windows, so I can't suggest
> what's the right way to do it. I will say though that most people
> run the postmaster as a background service on Windows, rather than
> launching it manually.
>

AFAIC Windows has no way to disassociate a process with a console window in
a similar way.

--
Magnus Hagander
Me: https://www.hagander.net/ <http://www.hagander.net/>
Work: https://www.redpill-linpro.com/ <http://www.redpill-linpro.com/>

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Kolla, Mahesh 2018-02-22 19:38:22 RE: BUG #15078: Unable to receive data from WAL Stream Error
Previous Message Kolla, Mahesh 2018-02-22 18:43:38 RE: BUG #15078: Unable to receive data from WAL Stream Error