I have a kernel module (a pseudo device driver actually) and also an auxiliary user-space process.
I want the kernel module to contact a user-space process during the process of rmmod, trigger the user-space process to do some clean-up work. I know I can send a signal from the kernel to the user process to trigger the clean-up, but I do need to send some other information to direct the user process as how to do the clean-up. (It is an array of integers, if that matters). I assume I can not pass any information along with the signal?
Do you guys know a way of doing it? I can not use ioctl, since the device would not be visible to the user-space process as it’s being rmmod’ed..
Thanks.
Such a design does not fit well with how the kernel works.
Instead, you should make the module report itself as in-use until the cleanup has been completed (so causing
rmmodto fail). When you want to unload the module, you should trigger the userspace cleanup to happen, then perform thermmodwhen it is complete (presumably with some kind of userspace script).You could implement this by having the userspace daemon hold a file descriptor open to the device provided by the kernel module, closing it once the userspace cleanup has happened.