Re: Question about Ctrl-C and less

From: Andrew - Supernews <andrew+nonews(at)supernews(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Question about Ctrl-C and less
Date: 2005-10-19 12:40:40
Message-ID: slrndlcfm8.2db7.andrew+nonews@trinity.supernews.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2005-10-19, Kevin Brown <kevin(at)sysexperts(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Martijn van Oosterhout 2005-10-19 13:29:24 Re: Question about Ctrl-C and less
Previous Message Andrew - Supernews 2005-10-19 12:31:46 Re: pg_dump permissions