Re: [HACKERS] psql and Control-C

From: Alfred Perlstein <bright(at)wintelcom(dot)net>
To: chris(at)bitmead(dot)com
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, PostgreSQL Development <pgsql-hackers(at)postgreSQL(dot)org>
Subject: Re: [HACKERS] psql and Control-C
Date: 2000-02-18 00:33:25
Message-ID: 20000217163325.A21720@fw.wintelcom.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

* Chris Bitmead <chrisb(at)nimrod(dot)itg(dot)telstra(dot)com(dot)au> [000217 16:20] wrote:
> Peter Eisentraut wrote:
> >
> > Some people have indicated that they don't like how psql currently handles
> > Control-C if no query is in progress. I consider the behaviour of the
> > shells desirable but, quite frankly, I don't know how to do it.
>
> The typical way to do this sort of thing is to longjmp back to the main
> loop. And I think if you look at sig.c in bash, this is probably what
> they are doing.
>
> > Actually, shouldn't a Ctrl-C in a script cancel the query *and* stop the
> > script at all times?
>
> Yes.

Whoa whoa... It's a bit more complicated than you think, there's a lot
of state that gets put into libpq, i guess the simplest way would be
to do so and also cancel the transaction, but a simple longjump won't
work reliably and you'd also have to take very careful steps to make
sure you handle everything _just right_ from a signal context.

I'd rather have the inconvience of psql exiting than a not entirely
thought out mechanism for doing this properly potentially having psql
run amok on my database. :)

--
-Alfred Perlstein - [bright(at)wintelcom(dot)net|alfred(at)freebsd(dot)org]

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Chris Bitmead 2000-02-18 01:19:51 Re: [HACKERS] psql and Control-C
Previous Message Peter Eisentraut 2000-02-18 00:25:02 Re: [HACKERS] psql and Control-C