herdd: replace task_duplicate test with fork test
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#include "queue.h"
|
||||
#include "runlevel.h"
|
||||
#include "service.h"
|
||||
#include "spawn.h"
|
||||
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
@@ -111,19 +112,15 @@ int main(int argc, const char *argv[], const char *envp[])
|
||||
}
|
||||
|
||||
runlevel_activate(rl);
|
||||
#if 1
|
||||
pid_t child = fork();
|
||||
kern_logf(" fork returned %d", child);
|
||||
|
||||
kern_handle_t new_task = 123, new_space = 456;
|
||||
kern_status_t status = task_duplicate(&new_task, &new_space);
|
||||
kern_logf(
|
||||
" task_duplicate returned %d (%x/%x)",
|
||||
status,
|
||||
new_task,
|
||||
new_space);
|
||||
|
||||
if (new_task == KERN_HANDLE_INVALID) {
|
||||
if (child == 0) {
|
||||
kern_log("this is the child");
|
||||
long r = printf("hello\n");
|
||||
kern_logf("printf returned %ld (%d)", r, (errno));
|
||||
execlp(NULL, NULL);
|
||||
} else {
|
||||
kern_log("this is the parent");
|
||||
long r = printf("goodbye\n");
|
||||
@@ -131,5 +128,6 @@ int main(int argc, const char *argv[], const char *envp[])
|
||||
}
|
||||
|
||||
kern_logf("exiting (%s)", strerror(EFTYPE));
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user