Question about Ctrl-C and less

Поиск
Список
Период
Сортировка
От Martijn van Oosterhout
Тема Question about Ctrl-C and less
Дата
Msg-id 20051016132547.GD5779@svana.org
обсуждение исходный текст
Ответы Re: Question about Ctrl-C and less  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: Question about Ctrl-C and less  (Josh Berkus <josh@agliodbs.com>)
Re: Question about Ctrl-C and less  (Martijn van Oosterhout <kleptog@svana.org>)
Список pgsql-hackers
This behaviour has been around so long that I've gotten used to it but
I've always considered it a bug. Yet it has never been fixed so I'm
going to ask if anybody else has issues with this behaviour.

Reproducing it is easy:

1. Set PAGER=less
2. Start psql
3. Type: \df
4. When output appears, hit Control-C

Now watch as both psql and less try to read your characters, each
getting about half and getting very confused. Even if you manage to get
one of the two to quit, your terminal is still left in a scrambled
state, generally requiring a soft-reset on the terminal.

The fix is easy: where currently the code with popen/pclose ignores
SIGPIPE, tell it to also ignore SIGINT and restore the normal signal
handler on quit. This is almost in line with the system() function
which blocks SIGQUIT and SIGINT while the subprocess is running.

This problem has been around for ever yet obviously not everybody runs
into it all the time like I do. Would patch to fix this be accepted or
is there a reason why not?

Actually, I'm somewhat in favour if getting rid of the longjmp from the
signal handler and instead setting a flag to be checked at strategic
points in the code to abort whatever it is doing. The current way leaks
memory like crazy. If you're worried about infinite loops there's
always SIGQUIT.

Thanks in advance,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Martijn van Oosterhout
Дата:
Сообщение: Re: PostgreSQL roadmap for 8.2 and beyond.
Следующее
От: Thomas Hallgren
Дата:
Сообщение: Advice needed concerning Win32 signals