mirror of
https://github.com/google/sandboxed-api.git
synced 2024-03-22 13:11:30 +08:00
Log when global forkserver is started and its exit status
PiperOrigin-RevId: 398232735 Change-Id: Ia0628cf2dee51a94938dae82bcb392384feeb74c
This commit is contained in:
parent
b470a6ece5
commit
c29c510e30
|
@ -119,6 +119,8 @@ GlobalForkserverStartModeSet GetForkserverStartMode() {
|
|||
}
|
||||
|
||||
absl::StatusOr<std::unique_ptr<GlobalForkClient>> StartGlobalForkServer() {
|
||||
SAPI_RAW_LOG(INFO, "Starting global forkserver");
|
||||
|
||||
// The fd is owned by EmbedFile
|
||||
int exec_fd = sapi::EmbedFile::instance()->GetFdForFileToc(
|
||||
forkserver_bin_embed_create());
|
||||
|
@ -168,10 +170,23 @@ absl::StatusOr<std::unique_ptr<GlobalForkClient>> StartGlobalForkServer() {
|
|||
}
|
||||
|
||||
void WaitForForkserver(pid_t pid) {
|
||||
pid_t wpid = TEMP_FAILURE_RETRY(waitpid(pid, nullptr, 0));
|
||||
int status;
|
||||
pid_t wpid = TEMP_FAILURE_RETRY(waitpid(pid, &status, 0));
|
||||
if (wpid != pid) {
|
||||
SAPI_RAW_PLOG(ERROR, "Waiting for %d failed", pid);
|
||||
}
|
||||
if (WIFEXITED(status)) {
|
||||
int exit_code = WEXITSTATUS(status);
|
||||
if (exit_code == 0) {
|
||||
SAPI_RAW_LOG(INFO, "forkserver (pid=%d) terminated normally", pid);
|
||||
} else {
|
||||
SAPI_RAW_LOG(WARNING, "forkserver (pid=%d) terminated with exit code %d",
|
||||
pid, exit_code);
|
||||
}
|
||||
} else if (WIFSIGNALED(status)) {
|
||||
SAPI_RAW_LOG(WARNING, "forkserver (pid=%d) terminated by signal %d", pid,
|
||||
WTERMSIG(status));
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
Loading…
Reference in New Issue
Block a user