aboutsummaryrefslogtreecommitdiff
path: root/src/jail.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/jail.c')
-rw-r--r--src/jail.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/src/jail.c b/src/jail.c
index 5b04a97..aa57581 100644
--- a/src/jail.c
+++ b/src/jail.c
@@ -115,8 +115,9 @@ int jail_setup_epoll(jail_ctx *ctx[], size_t siz)
return fd;
}
-int jail_daemonize_epoll(int epoll_fd, jail_ctx *ctx[], size_t siz)
+pid_t jail_daemonize_epoll(int epoll_fd, jail_ctx *ctx[], size_t siz)
{
+ pid_t p;
int s;
size_t i;
@@ -130,21 +131,21 @@ int jail_daemonize_epoll(int epoll_fd, jail_ctx *ctx[], size_t siz)
E_GAIERR(s, "Could not initialise jail daemon socket");
return 1;
}
+ }
- ctx[i]->jail_pid = fork();
- switch (ctx[i]->jail_pid) {
- case -1:
- W_STRERR("Jail daemonize");
- return 1;
- case 0:
- N("%s", "Jail daemon mainloop");
- jail_daemonfn_epoll(epoll_fd, ctx, siz);
- break;
- }
- D2("Jail daemon pid: %d", ctx[i]->jail_pid);
- }
+ p = fork();
+ switch (p) {
+ case -1:
+ W_STRERR("Jail daemonize");
+ return -1;
+ case 0:
+ N("%s", "Jail daemon mainloop");
+ jail_daemonfn_epoll(epoll_fd, ctx, siz);
+ break;
+ }
+ D2("Jail daemon pid: %d", p);
- return 0;
+ return p;
}
static int jail_daemonfn_epoll(int epoll_fd, jail_ctx *ctx[], size_t siz)