aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/libcasper/libcasper/libcasper_service.c12
-rw-r--r--lib/libcasper/libcasper/zygote.c6
2 files changed, 11 insertions, 7 deletions
diff --git a/lib/libcasper/libcasper/libcasper_service.c b/lib/libcasper/libcasper/libcasper_service.c
index b951de58d229..402a266bce68 100644
--- a/lib/libcasper/libcasper/libcasper_service.c
+++ b/lib/libcasper/libcasper/libcasper_service.c
@@ -222,8 +222,9 @@ service_register_core(int fd)
void
casper_main_loop(int fd)
{
+ int pfd, ret = 0;
- if (zygote_init() < 0)
+ if ((pfd = zygote_init()) < 0)
_exit(1);
/*
@@ -232,9 +233,12 @@ casper_main_loop(int fd)
service_register_core(fd);
while (service_have_connections()) {
- if (!service_poll_dispatch())
- _exit(1);
+ if (!service_poll_dispatch()) {
+ ret = 1;
+ break;
+ }
}
- _exit(0);
+ (void)close(pfd);
+ _exit(ret);
}
diff --git a/lib/libcasper/libcasper/zygote.c b/lib/libcasper/libcasper/zygote.c
index 574d80a16b01..2736957e82a1 100644
--- a/lib/libcasper/libcasper/zygote.c
+++ b/lib/libcasper/libcasper/zygote.c
@@ -188,13 +188,13 @@ send:
int
zygote_init(void)
{
- int serrno, sp[2];
+ int pfd, serrno, sp[2];
pid_t pid;
if (socketpair(PF_UNIX, SOCK_STREAM | SOCK_NONBLOCK, 0, sp) == -1)
return (-1);
- pid = fork();
+ pid = pdfork(&pfd, PD_NOWAITPID);
switch (pid) {
case -1:
/* Failure. */
@@ -213,7 +213,7 @@ zygote_init(void)
/* Parent. */
zygote_sock = sp[0];
close(sp[1]);
- return (0);
+ return (pfd);
}
/* NOTREACHED */
}