Re: loading kext from a daemon program
site_archiver@lists.apple.com Delivered-To: darwin-kernel@lists.apple.com On May 4, 2006, at 1:04 PM, Matt Ginzton wrote: ala (written from scratch, not even thrown to gcc for syntax checking) #include <stdio.h> #include <sys/types.h> pid_t pid; int status; /* if we got here, we're the parent, wait for kextload to finish */ if ((pid = waitpid(pid, &status, 0)) < 0) { perror("wait error"); } /* status will tell us if kextload finish with a non-zero exit code */ _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-kernel mailing list (Darwin-kernel@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-kernel/site_archiver%40lists.a... int result = execlp("kextload", "kextload", "<path to my kext>" (char *)0); this does load the kext but exists my daemon program, I am guessing because of what the documentation says that it replaces the current process image with the new process image. The normal Unix way of doing this is a combination of fork, exec, and wait. Fork creates a separate process, in which you can exec kextload, and then the parent process waits for the child to exit. if (( pid = fork()) < 0) { /* fork failed, not much we can do */ perror("fork error"); } else if (pid == 0) { /* child, execute kextload */ if (execlp("kextload", "kextload", "<path to module>", (char *)0) { perror("execlp error"); /* child doesn't get here on success of execlp */ exit(1); } } This email sent to site_archiver@lists.apple.com
participants (1)
-
Jim Thompson