Re: loading kext from a daemon program
Re: loading kext from a daemon program
- Subject: Re: loading kext from a daemon program
- From: Jim Thompson <email@hidden>
- Date: Thu, 4 May 2006 13:23:12 -0700
On May 4, 2006, at 1:04 PM, Matt Ginzton wrote:
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.
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 (( 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);
}
}
/* 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 (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden