herdd: implement service startup using posix_spawn

This commit is contained in:
2026-05-30 10:19:50 +01:00
parent 9dc3644fc1
commit aa60adf991
+19 -2
View File
@@ -11,6 +11,7 @@
#include <launch.h>
#include <magenta/log.h>
#include <rosetta/bootstrap.h>
#include <spawn.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -174,6 +175,22 @@ int service_start(struct service *svc)
{
log("Starting %s...", svc->s_description);
log_ok("Started %s.", svc->s_description);
return 0;
pid_t child = 0;
char *const argv[] = {
svc->s_name,
NULL,
};
int err = posix_spawn(&child, svc->s_exec, NULL, NULL, argv, NULL);
if (err == 0) {
log_ok("Started %s.", svc->s_description);
} else {
log_fail(
"Failed to start %s (%s)",
svc->s_description,
strerror(errno));
}
return err;
}