by Neil Parker
August 27, 1998
Updated July 26, 2003
Updated Novermber 17, 2019 (now frees SANE direct page)
Apple IIGS, System 4.0 or greater
In a nutshell, Sanitizer is an init for GS/OS that watches for programs that fail to shut down the SANE toolset, and when it sees such a program attempting to exit, it takes over briefly and forces SANE to be shut down.
In an ideal world, politicians would be honest, cars would run on water, and programs would always shut down the tools that they started before exiting. Sanitizer can't do anything about politicians or cars, but it can do something about the tools problem.
The SANE toolset, which many programs use to perform floating-point arithmetic, is especially a problem. I've encountered several different programs that fail to shut it down properly. This in not necessarily the fault of the programmer--some development environments (TML Pascal II, for example) ship with run-time libraries that start up SANE but don't shut it down (the TML Pascal II documentation makes no mention of this quirk).
Once a program has exited and left SANE running, the system isn't quite "safe" anymore. Another program (the Finder, for example) can claim the memory that SANE thinks it still owns, and then if something else tries to use SANE, all heck breaks loose. The Calculator desk accessory that ships with System 6.0 can easily trigger this--if you run a program that leaves SANE running, quit back to the Finder, and then try to use the Calculator, the screen starts to go crazy. Try it some day--it's spectacular to watch, in a morbid sort of way.
Just copy Sanitizer into the System:System.Setup folder of your boot disk, and reboot the system. (If you have IR installed, double-clicking on Sanitizer doesn't work--you must put Sanitizer in the System.Setup folder and reboot.)
When it first loads, Sanitizer checks the GS/OS version, and makes sure that the system is in the process of booting. If both these tests pass, it hooks itself into the GS/OS inline and stack-based call vectors, and installs a GS/OS notification procedure that reinstalls the call vector hooks on return from ProDOS 8. Otherwise it just exits and tries to unload itself. (The boot-time test is there to make sure Sanitizer gets installed before any application program, such as a shell, that also intercepts Quit calls, and as a primitive guard against having multiple Sanitizers in memory at the same time.)
The GS/OS call hooks look at the call number, and anything other than Quit ($0029 or $2029) is passed on to GS/OS. When it detects a Quit call, it calls SANEStatus, and if SANE is still running, it calls SANEShutDown, and disposes SANE's direct page handle. Then it passes the Quit on to GS/OS.
There are some potential dangers here. I'm totally unable to think of a legitimate reason why anything would need to leave SANE running across a Quit call, but it might be possible. If there is something out there that absolutely must leave SANE running, Sanitizer will clobber it. If you experience problems, disable Sanitizer and reboot.
There are a few cases where Sanitizer won't clean up a leftover SANE. Most shells intercept Quit calls before Sanitizer can see them, so if a shell command leaves SANE running, Sanitizer won't know anything about it. This might cause problems for subsequent shell commands, but the problem should solve itself when the shell quits.
Pick a format:
![]() |
Shrinkit archive (8466 bytes): Sanitizer.SHK |
![]() |
Zipped 5.25-inch ProDOS disk image (7357 bytes): Sanitizer.zip |