I've built an uninstaller that call helper executable with elevated permissions to remove my driver's launchd-plist, so that it won't come up again on the next boot cycle.
In order reflect the new stage of /Library/LaunchDaemons
, I invalidate the kextcache using the following command touch /Library/Extensions/
showed in this question.
However, when I do so from the helper executable right after the plist file was removed, it wouldn't succeed, and my driver still go up after reboot.
When I do it manually by typing the command touch /Library/Extensions
right after the uninstaller helper finish, it does the trick.
here's how my code looks like in the first option (invalidate from the helper exec).
remove(OSX_LAUNCHD_PLIST_PATH);
pid_t pid = -1;
char const * args[] = {"touch", "/Library/Extensions", NULL};
posix_spawn(&pid, "/usr/bin/touch", NULL, NULL, (char **)args, NULL);
waitpid(pid, &status, WNOHANG|WUNTRACED);
perhaps you could tell me why do I get different behaviour in each of the options.
UPDATE:
it seems like the cache invalidation requires to repeat this command more than once. This code worked to me, but i don't have a clue why ...
for (int x=0 ; x < 2; x++ ) {
char const * args[] = {"touch", "/Library/Extensions", NULL};
posix_spawn(&pid, "/usr/bin/touch", NULL, NULL, (char **)args, NULL);
waitpid(pid, &status, WNOHANG|WUNTRACED);
char const * args2[] = {"touch", "/System/Library/Extensions", NULL};
posix_spawn(&pid, "/usr/bin/touch", NULL, NULL, (char **)args2, NULL);
waitpid(pid, &status, WNOHANG|WUNTRACED);
}