Hotplug notifications
⭐ New in 0.2.9.
Hotplug notification subsystem depends on devd daemon, and is supported only on FreeBSD.
Functions
Each hotplug notification subsystem function explained.
hotplug_get_value
Get value for key when hotplug event occurs. In FreeBSD, key/value pairs can be seen for each event by catting /var/run/devd.seqpacket.pipe file and generating hotplug event somehow (terminal bell generates one). This function is only useable inside hotplug callback functions.
Returns value for key on success, nothing if key was not found or it has no value.
string hotplug_get_value([handle] hotplug_handle, [string] key)
- hotplug_handle is the handle passed to callback function as first parameter by the engine when callback function was started.
- key is the name of the key which value to get. Key name depends on event. Good grib sheet for key names is /var/run/devd.seqpacket.pipe file.
hotplug_init
Initialize hotplug subsystem to receive events when something worth notifying happens.
void hotplug_init([string] cb_attach, [string] cb_detach, [string] cb_notify)
- cb parameters are callback function names to call when corresponding event occurs.
Example:
main { hotplug_init (\ cb_attach: "cb_attach", \ cb_detach: "cb_detach", \ cb_notify: NULL) } _HOTPLUG_EVENT_ callback cb_attach (_hnd, _key, _val) { ; Handle _hnd is not valid after this function terminates ; print "Attached " . _key . "\n" _v = hotplug_get_value (\ handle: _hnd, \ key: "subsystem") print "Value for key: " . _v . "\n" _hnd.get_value("type") print "Value for another key: " . rc . "\n" } _HOTPLUG_EVENT_ callback cb_detach (_hnd, _key, _val) { ; Handle _hnd is not valid after this function terminates ; print "Detached " . _key . "\n" }
Copyright © 2025, Jani Salonen <salojan at goto10 piste co>. Piste is finnish word and means dot. All rights reserved.