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 16:18:06 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 23:16:47 GMT References: <5ee5b646.0208241822.34540e8b@posting.google.com> <3D6D00B9.60EECCFB@san.rr.com> <3D6D4F44.4872BCFA@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:28535 Date: 2002-08-28T23:16:47+00:00 List-Id: Darren New writes: > Robert A Duff wrote: > > > > 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? > > Well, it isn't the OS doing it. OK, I admit, I was oversimplifying. Still, if the OS allocates some physical memory to a process, and the process dies, the OS ought to reclaim that memory. If a license manager allocates a license to a process, and the process dies, the license manager ought to reclaim it. If an airline terminal crashes in the middle of allocating a seat, the seat should not be permanently empty on all further flights. My point is simply that "exit" shouldn't be any worse than a crash. And that we can't rely on Ada finalization for those sorts of cleanup. > > The OS has to recover from those nasties > > without leaking resources. > > It doesn't recover from those nasties without leaking resources. > > > So surely calling "exit" is no worse. > > Correct. I'm not arguing that you shouldn't have "exit". I'm merely saying > that "the OS cleans up all externally-visible resources" is an > oversimplification. Agreed. > > I don't know Amiga, but it seems to me that if a crashed program causes > > memory leaks, the OS is broken. > > No more than "a crashed program might leave half-written temp files around" > is "broken". I suppose, if somebody can clean up that memory without rebooting. > > > 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. > > I think it more depends on what you mean by "resources". I've worked on OSes > where you had "temp files" that went away when you logged out. UNIX doesn't > have that. Are junk-files in /tmp a "resource leak" the OS should clean up? I don't know. I suppose Unix is broken in that regard. I must admit that I've had to delete "by hand" some junk in /tmp, which rogue programs left lying around. - Bob