Refactoring for internal change

PiperOrigin-RevId: 320612442
Change-Id: I65729ac5d83c76dac047a47f866b7ad4af3c56c1
This commit is contained in:
Chris Kennelly 2020-07-10 09:01:17 -07:00 committed by Copybara-Service
parent c3861819bc
commit 63a8b3ff15
4 changed files with 12 additions and 4 deletions

View File

@ -499,7 +499,6 @@ cc_library(
"//sandboxed_api/sandbox2/util:fileops",
"//sandboxed_api/sandbox2/util:strerror",
"//sandboxed_api/util:raw_logging",
"//sandboxed_api/util:status",
"//sandboxed_api/util:statusor",
"@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/strings",

View File

@ -304,7 +304,10 @@ void ForkServer::LaunchChild(const ForkRequest& request, int execve_fd,
// A custom init process is only needed if a new PID NS is created.
if (request.clone_flags() & CLONE_NEWPID) {
// Spawn a child process
pid_t child = fork();
pid_t child;
{
child = fork();
}
if (child < 0) {
SAPI_RAW_PLOG(FATAL, "Could not spawn init process");
}

View File

@ -77,7 +77,10 @@ static void StartGlobalForkServer() {
"creating socket pair");
// Fork the fork-server, and clean-up the resources (close remote sockets).
pid_t pid = fork();
pid_t pid;
{
pid = fork();
}
SAPI_RAW_PCHECK(pid != -1, "during fork");
// Parent.

View File

@ -133,7 +133,10 @@ pid_t CloneAndJump(int flags, jmp_buf* env_ptr) {
#else
#error "Architecture is not supported"
#endif
int r = clone(&ChildFunc, stack, flags, env_ptr, nullptr, nullptr, nullptr);
int r;
{
r = clone(&ChildFunc, stack, flags, env_ptr, nullptr, nullptr, nullptr);
}
if (r == -1) {
SAPI_RAW_PLOG(ERROR, "clone()");
}