Is there a way to force-close any app at any time?

Hello everyone, I’m new to the 68K Mac. I’m trying to write code in the emulator, but my code crashes frequently. I don’t know how to force-quit an app stuck in an infinite loop, so I’m wondering if there’s a tool similar to `kill 9` in Linux that can force-quit an app. Thanks in advance.
 
click on the app that's stuck in an infinite loop, hit hold command (Apple) and option (alt), and press escape, you should see a dialog box that says "force quit 'app'?" click OK
 
It sometimes works but sometimes it either freezes the machine or leads to weirdness later. I only ever use it to get a chance to save and reboot in an orderly fashion.
 
Yeah, remember the classic Mac OS doesn't have protected memory, so really if your program has crashed you should probably restart anyway, even if you successfully force quit.
 
If you can't successfully force quit, the solution is to hit the interrupt key (or programmer's key combo, depending on the device), and do:
SM FA700 A9F4
PC FA700
G
First line sets the memory at address FA700 (usually a safe range to overwrite) to A9F4 ("exit to shell" trap).
Second line sets the program counter to that address (telling the computer to process from that memory address next)
Third line runs from the current address, causing the OS to trigger an "exit to shell" event, which SHOULD drop you back into the Finder.

At that point, you want to Special -> Shut Down, as things will be almost guaranteed to be unstable and crash-prone. Gives you the option to cleanly shut down instead of just rebooting though.

Since you're writing your own code, you're probably dropping in and out of the debugger. You can just use that same minibug routine but set the memory at whatever address is safe in your existing stack to A9F4 and run it. Or, you can pre-set an address in your own stack to A9F4, and have a debug handler that points to that address if you get into a nested loop situation beyond a specified depth.
 
If you can't successfully force quit, the solution is to hit the interrupt key (or programmer's key combo, depending on the device), and do:
SM FA700 A9F4
PC FA700
G
First line sets the memory at address FA700 (usually a safe range to overwrite) to A9F4 ("exit to shell" trap).
Second line sets the program counter to that address (telling the computer to process from that memory address next)
Third line runs from the current address, causing the OS to trigger an "exit to shell" event, which SHOULD drop you back into the Finder.

At that point, you want to Special -> Shut Down, as things will be almost guaranteed to be unstable and crash-prone. Gives you the option to cleanly shut down instead of just rebooting though.

Since you're writing your own code, you're probably dropping in and out of the debugger. You can just use that same minibug routine but set the memory at whatever address is safe in your existing stack to A9F4 and run it. Or, you can pre-set an address in your own stack to A9F4, and have a debug handler that points to that address if you get into a nested loop situation beyond a specified depth.
Thank you, I'm a bit afraid to use the interrupt key, because my emulator is not very stable under the built-in debugger, and I still don't know why.
 
Yeah, remember the classic Mac OS doesn't have protected memory, so really if your program has crashed you should probably restart anyway, even if you successfully force quit.
Thank you, because I am not very familiar with how to write UI code, I often encounter infinite loops. I think this shouldn't be a big problem?
 
Thank you, I'm a bit afraid to use the interrupt key, because my emulator is not very stable under the built-in debugger, and I still don't know why.
In that case, go with my last suggestion, and for your debug code version, keep a loop counter and a pre-populated A9F4 that your exception handler can call.
 
Back
Top