From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,f6ee8ca03c176d76 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-08-28 15:23:18 PST Newsgroups: comp.lang.ada Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!arclight.uoregon.edu!news.tufts.edu!uunet!dca.uu.net!ash.uu.net!world!news From: Robert A Duff Subject: Re: stupid question: how can I finish a program? Sender: news@world.std.com (Mr Usenet Himself) Message-ID: Date: Wed, 28 Aug 2002 22:22:56 GMT References: <5ee5b646.0208241822.34540e8b@posting.google.com> <3D6D00B9.60EECCFB@san.rr.com> NNTP-Posting-Host: shell01.theworld.com Organization: The World Public Access UNIX, Brookline, MA X-Newsreader: Gnus v5.7/Emacs 20.7 Xref: archiver1.google.com comp.lang.ada:28528 Date: 2002-08-28T22:22:56+00:00 List-Id: Darren New writes: > Robert A Duff wrote: > > If you're running under a proper operating system, then all resources > > visible outside the program will be cleaned up when the program exits. > > This is true only in the most trivial sense. If I have a program that > contacts a license manager (for example) and grabs the license, then aborts, > I could be in trouble. That's why license managers check for that sort of > failure. So if it's checked for, what's the problem? My point is that any process can be killed at any point. The process could execute an illegal instruction (Ada allows calls to machine code, for example, and allows Unchecked_Conversion to pointers). Or (in Unix), you can "kill -9" it. The OS has to recover from those nasties without leaking resources. So surely calling "exit" is no worse. >... If I create a lock-file, that lock-file doesn't get cleaned up > (under UNIX, for example). That's why I said, "So you can't blithely call "exit" without some global knowledge of how finalization is used in your program." A program that acquires lock files ought to be robust. For example, check whether a previous dead version of itself created the lock file. > Other OSes (like Amiga's OS) specifically don't clean up anything at all, as > this lets you do things like allocate memory, load a program into it, and > start it up and then exit yourself. You have to clean it up for yourself. I don't know Amiga, but it seems to me that if a crashed program causes memory leaks, the OS is broken. > Some mainframe OSes leave the clean-up to the shell. It's the shell's > responsibility to free the memory and close the files. However, I'd expect > that one would count the shell as "part of the OS" in these systems. And one thing Unix does right is to make shells *not* part of the OS. > So no, in general, a "proper" operating system doesn't clean up all visible > resources. Not even with exit() calls. :-) I guess it depends on what "proper" OS means. I'm assuming hardware memory protection, and an OS that takes advantage of that to reclaim resources from crashed processes. - Bob