mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-12-22 09:41:54 +00:00
Flock: Even more fd cleanup
This commit is contained in:
parent
77e21c6b7d
commit
08b052f8b4
@ -470,12 +470,6 @@ container_start(void)
|
|||||||
log(L_INFO "Requested to start a container, name %s, base %s, work %s",
|
log(L_INFO "Requested to start a container, name %s, base %s, work %s",
|
||||||
ccf.hostname, ccf.basedir, ccf.workdir);
|
ccf.hostname, ccf.basedir, ccf.workdir);
|
||||||
|
|
||||||
/* create socketpair before forking to do communication */
|
|
||||||
int fds[2];
|
|
||||||
int e = socketpair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0, fds);
|
|
||||||
if (e < 0)
|
|
||||||
die("Failed to create internal socketpair: %m");
|
|
||||||
|
|
||||||
pid_t pid = fork();
|
pid_t pid = fork();
|
||||||
if (pid < 0)
|
if (pid < 0)
|
||||||
die("Failed to fork container (parent): %m");
|
die("Failed to fork container (parent): %m");
|
||||||
@ -505,7 +499,7 @@ container_start(void)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
e = unshare(CLONE_NEWPID | CLONE_NEWNS | CLONE_NEWTIME | CLONE_NEWNET);
|
int e = unshare(CLONE_NEWPID | CLONE_NEWNS | CLONE_NEWTIME | CLONE_NEWNET);
|
||||||
if (e < 0)
|
if (e < 0)
|
||||||
die("Failed to unshare container: %m");
|
die("Failed to unshare container: %m");
|
||||||
|
|
||||||
@ -519,6 +513,14 @@ container_start(void)
|
|||||||
#undef FROB
|
#undef FROB
|
||||||
sigprocmask(SIG_BLOCK, &newmask, &oldmask);
|
sigprocmask(SIG_BLOCK, &newmask, &oldmask);
|
||||||
|
|
||||||
|
/* create socketpair before forking to do communication */
|
||||||
|
int fds[2];
|
||||||
|
e = socketpair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0, fds);
|
||||||
|
if (e < 0)
|
||||||
|
die("Failed to create internal socketpair: %m");
|
||||||
|
|
||||||
|
log("container fork socketpair: %d %d", fds[0], fds[1]);
|
||||||
|
|
||||||
pid = fork();
|
pid = fork();
|
||||||
if (pid < 0)
|
if (pid < 0)
|
||||||
die("Failed to fork container (child): %m");
|
die("Failed to fork container (child): %m");
|
||||||
|
Loading…
Reference in New Issue
Block a user