Add missing chdir() in the init process

PiperOrigin-RevId: 239425921
Change-Id: Ia1b02ae0a2f319faa601d6098a9f94a3043656a8
This commit is contained in:
Kevin Hamacher 2019-03-20 10:35:47 -07:00 committed by Copybara-Service
parent 52f4c1f927
commit 1dd0428713

View File

@ -158,6 +158,7 @@ static void RunInitProcess(int signaling_fd, std::set<int> open_fds) {
} else if (child > 0) { } else if (child > 0) {
// Perform some sanitization (basically equals to SanitizeEnvironment // Perform some sanitization (basically equals to SanitizeEnvironment
// except that it does not require /proc to be available). // except that it does not require /proc to be available).
SAPI_RAW_CHECK(chdir("/") == 0, "changing init cwd failed");
setsid(); setsid();
if (prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0) != 0) { if (prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0) != 0) {
SAPI_RAW_PLOG(ERROR, "prctl(PR_SET_PDEATHSIG, SIGKILL) failed"); SAPI_RAW_PLOG(ERROR, "prctl(PR_SET_PDEATHSIG, SIGKILL) failed");