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

From Andrew - Supernews
Subject Re: Question about Ctrl-C and less
Date
Msg-id slrndlcfm8.2db7.andrew+nonews@trinity.supernews.net
Whole thread Raw
In response to Question about Ctrl-C and less  (Martijn van Oosterhout <kleptog@svana.org>)
Responses Re: Question about Ctrl-C and less
List pgsql-hackers
On 2005-10-19, Kevin Brown <kevin@sysexperts.com> wrote:
> Making assumptions about what the pager will do upon receipt of SIGINT
> is folly as well.
>
> Setting up SIGINT to be ignored may be the right answer (I don't
> believe it is -- see below), but if so then it needs to be done
> properly.  If it gets ignored prior to the popen(), then the child
> will also end up ignoring it by default, because signal disposition is
> inherited by child processes.  If we ignore SIGINT, it should be after
> the popen(), not before.

I do not believe it is possible to do the signal disposition correctly
and still use popen() to run the pager. (You would need to reimplement
popen using raw syscalls.)

> So I think the right answer here is for psql to handle SIGINT
> internally by doing a pclose() first

The chances that psql can do this safely approach zero. pclose() is not a
signal-safe function, so it can only be called from a signal handler if
you _know_ that the signal did not interrupt any non-signal-safe function.
(Nor can the signal handler longjmp out in such a case, unless the code is
never again going to call any unsafe function.)

-- 
Andrew, Supernews
http://www.supernews.com - individual and corporate NNTP services


pgsql-hackers by date:

Previous
From: Andrew - Supernews
Date:
Subject: Re: pg_dump permissions
Next
From: Ivan Pavlov
Date:
Subject: Re: [GENERAL] Call for translators