I’m sorry, but have you ever written a program that requires any serious cleanup? Because you’re beginning to sound like you haven’t. Yes, the OS can deallocate a block on the heap or close files. In your other post you mentioned the Unix ‘kill -9’ command, which does these things. Windows has something similar, through the Task Manager. But that’s forced termination without the benefit of cleanup, and there’s a big difference between that and a “graceful” shutdown.
Some programs open data files with write access, and need to set them to certain states before closing or risk data loss or corruption. (Especially certain database styles! One game I have is pretty stable, and I’m glad about that because if it ever crashes you have to reinstall the whole program to fix the resulting database corruption.) Some programs open network connections to other computers and would like to let the other system know they’re logging off. And if you’re working directly with video memory, terminating abruptly under certain circumstances can leave it in an undefined state, with all sorts of nasty consequences for the rest of the system. These are things that the OS can’t handle automatically because it doesn’t know the details.
- is not a “kill” command. It’s a “close” command. It’s another way to do the exact same thing as clicking the red X in the corner: send a signal through Windows’s event system to the program that it’s time to close the current window, which usually also means shutting down the program, unless there are other independent windows active. The program is then responsible for actually closing the window when it receives this event, giving it the chance to clean up after itself. In other words, precisely what SDL_QUIT is there for.
The original point that was made is that clicking the X button generates an SDL_QUIT event, and under Windows - is supposed to be EXACTLY functionally equivalent to it, but it isn’t because SDL grabs input away from the window controller and someone overlooked that. The Mac has something similar, the - combination, which also ought to automatically generate SDL_QUIT on a Mac. Not sure about *nix, but if it does, then that keystroke should do the same under *nix platforms. It’s part of the “SDL just works” magic that makes so many of us like programming with it.
Besides, Sam’s already acknowledged this as a bug. So would you mind dropping the “Windows is not God” crusading, please?> ----- Original Message -----
From: j_post@pacbell.net (Jeff Post)
To: A list for developers using the SDL library. (includes SDL-announce)
Sent: Wednesday, April 30, 2008 10:34:34 PM
Subject: Re: [SDL] Alt-F4 not working on Windows
On Wed April 30 2008 20:22, Mason Wheeler wrote:
Windows (or any operating system) can’t gracefully terminate any
? non-trivial program. The program has to gracefully terminate itself with
its own cleanup routines to take care of allocated memory, temporary files,
network connections, and howevermany other things.
Any decent OS will indeed take care of allocated memory, temp files, and other
resources used by a program when it terminates. I believe even Windows does,
but since I don’t use Windows I can’t say for sure.
Jeff