ADC Home > Reference Library > Technical Q&As > Darwin > Hardware & Drivers >

Installing an I/O Kit KEXT Without Rebooting


Q: Is it possible to install an I/O Kit KEXT without requiring a restart?

A: There is no easy solution to this problem. Currently, even Apple's own installers require restarting after a KEXT installation. Here's why this is more complicated than it may seem.

If another driver is currently matched to your device, that driver has to be unloaded first. This in turn means that the device can't be in use. Plus, the preferred mechanism for updating the system's list of known KEXTs does not exist in older releases of Mac OS X.

Given those considerations, here is the logic you should use:

  1. If the release is < 10.3 (prior to Panther), require a restart.
  2. If the release is >= 10.3 and kextd is NOT running, require a restart. A shell script can determine whetherkextd is running using the code in Listing 1 . This code will return the PID of kextd if it is running, or return nothing if it isn't.
  3. If the release is >= 10.3 AND kextd is running, send kextd a SIGHUP signal as shown in Listing 2 :



Listing 1. Determining whether kextd is running.

ps -ax | awk '{print $1" "$5}' | grep kextd | awk '{print $1}'





Listing 2. Sending a SIGHUP to kextd.

/bin/kill -1 `ps -ax | awk '{print $1" "$5}' | grep kextd | \
awk '{print $1}'`



In the future we may have a formal API for this, so there may eventually be an option 4, but the logic above will continue to function correctly even in that case. It is important that your install script cope with the case where kextd is not running.

Q: Can't I just fork/exec kextload to load my KEXT?

A: This approach has its own pitfalls. If you run kextload but the user waits longer than about a minute to plug in the device, your driver will be unloaded and another matching driver will be loaded for your device instead. And, even if the user plugs in the device promptly, if they unplug the device later, your driver will still be unloaded after a minute. You're now back to the first situation because kextd isn't aware of your KEXT if you've loaded it by hand using kextload.kextd enumerates available KEXTs only at startup or in response to a SIGHUP in those versions that support that signal.


[Oct 28, 2003]


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.