herdd: replace task_duplicate test with fork test

This commit is contained in:
2026-05-30 10:20:21 +01:00
parent aa60adf991
commit afb20bf59d
+7 -9
View File
@@ -2,6 +2,7 @@
#include "queue.h" #include "queue.h"
#include "runlevel.h" #include "runlevel.h"
#include "service.h" #include "service.h"
#include "spawn.h"
#include <dirent.h> #include <dirent.h>
#include <errno.h> #include <errno.h>
@@ -111,19 +112,15 @@ int main(int argc, const char *argv[], const char *envp[])
} }
runlevel_activate(rl); runlevel_activate(rl);
#if 1
pid_t child = fork();
kern_logf(" fork returned %d", child);
kern_handle_t new_task = 123, new_space = 456; if (child == 0) {
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) {
kern_log("this is the child"); kern_log("this is the child");
long r = printf("hello\n"); long r = printf("hello\n");
kern_logf("printf returned %ld (%d)", r, (errno)); kern_logf("printf returned %ld (%d)", r, (errno));
execlp(NULL, NULL);
} else { } else {
kern_log("this is the parent"); kern_log("this is the parent");
long r = printf("goodbye\n"); 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)); kern_logf("exiting (%s)", strerror(EFTYPE));
#endif
return 0; return 0;
} }