Re: longjmp in psql considered harmful

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: longjmp in psql considered harmful
Дата
Msg-id 14049.1150157641@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: longjmp in psql considered harmful  (Martijn van Oosterhout <kleptog@svana.org>)
Ответы Re: longjmp in psql considered harmful  (Martijn van Oosterhout <kleptog@svana.org>)
Список pgsql-hackers
Martijn van Oosterhout <kleptog@svana.org> writes:
> But the effect would change still, even with readline enabled. If
> readline is compiled in and you press control-C, our handler is still
> called. Currently, we siglongjmp out of readline() and start again. If
> you only set a flag like proposed, we won't break out of the readline
> call. readline will clear any partial state, but that's it.

I had interpreted the readline documentation to mean that readline would
discard a partially typed line upon catching SIGINT.  Experimentation
shows that this is not so, at least not with the version of readline I
use here.  It does catch the signal and reset some internal state, but
the partially typed line is NOT discarded.  Grumble.

So I think this patch's basic approach is right: we need to set a flag
to allow the longjmp only when we are inside readline or fgets.  (I
looked a bit at the readline sources, and it does seem designed to block
signals when it's doing something it doesn't want interrupted, so we'll
assume it's doing it correctly.)

I'll work on reviewing and applying the patch.  I don't much like the
side-effects on the /scripts directory though ... there must be a better
way than that.  Is it sane to declare the flag variable in print.c?
        regards, tom lane


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: [PATCHES] Non-transactional pg_class, try 2
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: CSV mode option for pg_dump