Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!sdd.hp.com!wuarchive!uunet!zephyr.ens.tek.com!uw-beaver!milton!sumax!polari!rwing!seaeast!sunbrk!Usenet From: Antony.Hodgson@sunbrk.FidoNet.Org (Antony Hodgson) Newsgroups: comp.lang.c++ Subject: Re: How do I call destructors on ^C in TC++? Message-ID: <675518012.26@sunbrk.FidoNet> Date: 24 May 91 21:24:06 GMT Sender: Usenet@sunbrk.FidoNet.Org Lines: 23 In article <1991May24.045847.24401@colorado.edu> scholes@spot.Colorado.EDU (Genuine Bud Man) writes: > Please excuse me if this is a FAQ, or if I am missing something >painfully obvious, but destructors don't seem to be called when >the user hits ^C in Turbo C++. .. stuff deleted >The problem is that when the user types ^C, the destructors are not called, >and if the memory is in XMS or disk, then the XMS is not freed, or the >swap file not deleted. > I could easily write a ^C handler, and intercept ^C, but how >would the handler know who to call, since the class instances are >auto vars of another function? If ^C does the equivalent of exit(), then only global variable destructors are called. If it does the equivalent of abort(), no destructors are ever called. Borland C++ does have the atexit pragma, but since you can't pass parameters to it, you must have global variables available to tell you what swap files exist or what XMS blocks are not yet freed. Tony Hodgson ahodgson@hstbme.mit.edu * Origin: Seaeast - Fidonet<->Usenet Gateway - sunbrk (1:343/15.0)