herdd: implement service startup using posix_spawn
This commit is contained in:
@@ -11,6 +11,7 @@
|
|||||||
#include <launch.h>
|
#include <launch.h>
|
||||||
#include <magenta/log.h>
|
#include <magenta/log.h>
|
||||||
#include <rosetta/bootstrap.h>
|
#include <rosetta/bootstrap.h>
|
||||||
|
#include <spawn.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -174,6 +175,22 @@ int service_start(struct service *svc)
|
|||||||
{
|
{
|
||||||
log("Starting %s...", svc->s_description);
|
log("Starting %s...", svc->s_description);
|
||||||
|
|
||||||
log_ok("Started %s.", svc->s_description);
|
pid_t child = 0;
|
||||||
return 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;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user