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

From Kevin Brown
Subject Re: Question about Ctrl-C and less
Date
Msg-id 20051020224209.GD14950@filer
Whole thread Raw
In response to Re: Question about Ctrl-C and less  (Martijn van Oosterhout <kleptog@svana.org>)
Responses Re: Question about Ctrl-C and less
List 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@sysexperts.com


pgsql-hackers by date:

Previous
From: Simon Riggs
Date:
Subject: Re: Seeing context switch storm with 10/13 snapshot of
Next
From: Robert Creager
Date:
Subject: Re: Seeing context switch storm with 10/13 snapshot of