Re: Question about Ctrl-C and less

From: Kevin Brown <kevin(at)sysexperts(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Question about Ctrl-C and less
Date: 2005-10-22 09:24:20
Message-ID: 20051022092420.GG14950@filer
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)sysexperts(dot)com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dave Page 2005-10-22 09:31:56 Re: [PATCHES] Win32 CHECK_FOR_INTERRUPTS() performance
Previous Message Andreas Pflug 2005-10-22 09:04:53 Re: [Slony1-general] Slony1_funcs broken with 8.1