Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IHo13-0008D9-Q8 for qemu-devel@nongnu.org; Sun, 05 Aug 2007 17:52:01 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IHo0y-0008CB-RS for qemu-devel@nongnu.org; Sun, 05 Aug 2007 17:52:01 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IHo0y-0008C7-LQ for qemu-devel@nongnu.org; Sun, 05 Aug 2007 17:51:56 -0400 Received: from erizo.shearer.org ([210.10.97.33] helo=shearer.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.60) (envelope-from ) id 1IHo0w-0003CG-Ja for qemu-devel@nongnu.org; Sun, 05 Aug 2007 17:51:55 -0400 Received: from localhost ([127.0.0.1]:39514 helo=shearer.org) by shearer.org with esmtp (Dan's MTA 1.0) id 1IHo0R-0000qi-3t for qemu-devel@nongnu.org; Mon, 06 Aug 2007 07:21:23 +0930 Received: from dan by erizo.shearer.org with local (Spammer Slammer 3.141) id 1IHo0P-0000qf-Lv for qemu-devel@nongnu.org; Mon, 06 Aug 2007 07:21:21 +0930 Date: Mon, 6 Aug 2007 07:21:21 +0930 From: Dan Shearer Subject: Re: [Qemu-devel] Why not use exit() instead of abort()? Message-ID: <20070805215121.GB17778@erizo.shearer.org> References: <20070805211355.GA2888@chrom.inf.tu-dresden.de> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <20070805211355.GA2888@chrom.inf.tu-dresden.de> Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org On Sun, Aug 05, 2007 at 11:13:55PM +0200, Bernhard Kauer wrote: > There are a couple of places in qemu, where abort() is called. > The most commonly used one is perhaps cpu_abort() which is called > e.g. when a triple fault occures. > > As abort() does not call any atexit() function, cleanup is not > performed. Tiny correction: abort() and _exit don't call atexit(), however unix-like OSs still cleanup memory and file descriptors and other transient resources anyway no matter how the program ended. So lack of cleanup isn't quite as big an issue as it might seem. > This leaves for example the terminal in a state where > the cursor is invisible. Non-transient resources such as DSOs and domain sockets are not cleaned up by the OS, which accounts for the terminal problem you noticed. > Are there any reasons not to use exit(1) in cpu_abort()? Speed. I used to use abort() or _exit() for speed, ie they didn't hang around while atexit() waited politely for timeouts. I thought if I told the program to stop it should stop immediately :-) Then I had all sorts of problems to do with persistent shared resources hanging around in strange states so I moved to exit(1). I think (can someone correct me here?) there is another reason to call atexit() for portable programs, and that is that Microsoft OSs aren't as fussy about cleaning up after a program has exited. -- Dan Shearer dan@shearer.org