Re: Question about Ctrl-C and less - Mailing list pgsql-hackers

From Kevin Brown
Subject Re: Question about Ctrl-C and less
Date
Msg-id 20051022092420.GG14950@filer
Whole thread Raw
In response to Re: Question about Ctrl-C and less  ("Sean Utt" <sean@strateja.com>)
List pgsql-hackers
Sean Utt wrote:
> 
> If you send a recent version of vim a CONTROL-C, and you're just sitting
> there at a prompt, it gives you a hint:
> 
> Type  :quit<Enter>  to exit Vim
> 
> Any reason not to just trap the CONTROL-C in psql when paging and offer a
> hint? Especially since we don't really know that the user really wanted to
> type CONTROL-C instead of q for quit. I know that I have always meant to
> type q and was just distracted whenever I've typed CONTROL-C in the pager,
> and so passing the CONTROL-C on to less is not actually "heeding my wishes",
> it is instead giving me enough rope to shoot myself in the foot.

It won't work properly that way.  SIGINT gets sent to all the members
of the process group, not just the child.  Psql isn't responsible for
sending ctrl-c through to the child.

When you're in an editor such as vi that makes use of the terminal,
the editor itself is likely the only program that is doing anything.
Its parent is doing a wait() on the editor.  The parent in that
instance can ignore SIGINT because it's not involved at all at that
point.

That's not the case here.  Psql and the pager are really two
cooperating parts of the same task.  They just happen to be running in
two different process spaces.  Because they're both cooperatively
active at the same time, they both need to handle SIGINT, because when
the user invokes SIGINT, he intends for the overall task to return
some kind of control to him.  For psql, which is gathering data and
sending it to the pager, that means that it needs to stop doing so and
wait for the pager to finish.  For the pager, it means at a minimum
that it needs to display what it has so far and give interactive
control to the user (it may or may not attempt to continue to read
what's being sent to it).  Some pagers (like "more") will just exit.



-- 
Kevin Brown                          kevin@sysexperts.com


pgsql-hackers by date:

Previous
From: Andreas Pflug
Date:
Subject: Re: [Slony1-general] Slony1_funcs broken with 8.1
Next
From: Dave Page
Date:
Subject: Re: [PATCHES] Win32 CHECK_FOR_INTERRUPTS() performance