ctrl+c and destructors

H. S. Teoh hsteoh at quickfur.ath.cx
Tue Oct 1 07:52:05 PDT 2013


On Tue, Oct 01, 2013 at 02:06:12PM +0200, deadalnix wrote:
> On Monday, 30 September 2013 at 22:55:22 UTC, H. S. Teoh wrote:
> >On Mon, Sep 30, 2013 at 08:44:36PM +0200, deadalnix wrote:
> >>On Monday, 30 September 2013 at 02:13:47 UTC, H. S. Teoh wrote:
> >>>Well, ctrl-C can be handled, so the way I'd do it is to set up a
> >>>signal handler for SIGINT and have it write something to a
> >>>self-pipe read by the event handler, then the event handler can
> >>>throw an Exception (which should cause dtors to run as the stack
> >>>unwinds).
> >>>
> >>
> >>No you can't.
> >>
> >>But you somehow can, if you want to use some black magic :
> >>http://www.deadalnix.me/2012/03/24/get-an-exception-from-a-segfault-on-linux-x86-and-x86_64-using-some-black-magic/
> >
> >We were talking about SIGINT, not SIGSEGV.
> >
> 
> That isn't relevant here.

Huh? The OP was talking about cleaning up after ctrl-C, not after a
segfault. I already know you can't throw exceptions from a segfault
(except with heavy trickery, and yes I remember the post you linked and
I know how it works).

SIGINT is different because it can be handled, and the signal handler
can just write a byte to a pipe read by the main event loop, outside of
signal handler context.


T

-- 
Klein bottle for rent ... inquire within. -- Stephen Mulraney


More information about the Digitalmars-d mailing list