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-20 22:42:10
Message-ID: 20051020224209.GD14950@filer
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Martijn van Oosterhout wrote:
> You can't do a pclose in a signal handler, it's not one of the
> "reeentrant safe" functions and could lead to deadlocks. The signal
> manpage documents the ones you can use. Just set a flag. Setting the
> descriptor to NULL is worse because then we have check before every
> output function. fprintf(NULL, ...) will segfault on most
> architechtures I wager.

Yeah, I was thinking that you'd do the check for the flag and invoke a
cleanup handler after the write() to the output file descriptor. It's
not clear that you'd need to do the check anyplace else. It's been a
while since I've messed with this stuff, but if I recall correctly,
the write() will return immediately after receipt of a signal, and
will indicate how much was actually written. So receipt of a SIGINT
should wind up being handled in a reasonably timely fashion.

Additionally the normal SIGINT signal handler (the one that gets
invoked when the pager is turned off) can be called from the cleanup
handler in order to maintain the proper semantics.

--
Kevin Brown kevin(at)sysexperts(dot)com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Creager 2005-10-20 22:54:07 Re: Seeing context switch storm with 10/13 snapshot of
Previous Message Simon Riggs 2005-10-20 22:28:21 Re: Seeing context switch storm with 10/13 snapshot of