Newsgroups: comp.lang.c++ Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!csn!boulder!spot.Colorado.EDU!scholes From: scholes@spot.Colorado.EDU (Genuine Bud Man) Subject: How do I call destructors on ^C in TC++? Message-ID: <1991May24.045847.24401@colorado.edu> Originator: scholes@spot.Colorado.EDU Sender: news@colorado.edu (The Daily Planet) Nntp-Posting-Host: spot.colorado.edu Organization: University of Colorado, Boulder Date: Fri, 24 May 1991 04:58:47 GMT Lines: 20 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++. I developed a class library for giving "sort of" virtual data space. The program requests X amount of mem, and the class tries to satisfy the request first thru main memory, XMS, then disk space. I have alloc, read, write, and free functions. Each class instance may only be manipulating one block of memory at a time, so multiple class instances are running (at least in my stat app). 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? I could have the handler ignore ^C, but I would like to have that functionality. I am new to C++, so there may be something staring me in the face here, but I am lost as to what to do. I guess the same basic problem would exist in C, so how would it be handled? Global variables? Thanx in advance, Marty