Native driver killIO routines take the following form:
OSErr DoKillIOCommand (ParmBlkPtr thePb)
/* check internal queue for request to be killed; */
/* if found, remove from queue and free request */
{
return noErr;
}
/* else, if no request located */
return abortErr;
When the Device Manager receives a KillIO request, it removes the specified parameter block from the driver I/O queue. If the driver responds to any requests asynchronously, the part of the driver that completes asynchronous requests (such as an interrupt handler) might expect the parameter block for the pending request to be at the head of the queue. The Device Manager notifies the driver of KillIO requests so it can take the appropriate actions to stop work on any pending requests. After processing the KillIO call, the driver should check whether the kImmediateIOCommandKind bit is set in the IOCommandKind parameter and return the KillIO result to the Device Manager. Listing 8-2 shows an example in which the DoKillIOCmd case shows correct handling of the killIO routine.