Add IsStarted() method to GlobalForkClient.

PiperOrigin-RevId: 351170872
Change-Id: I5544eb27962606a562ce79b97d508f841ec0dc56
This commit is contained in:
Sandboxed API Team 2021-01-11 09:33:32 -08:00 committed by Copybara-Service
parent 3d737e3830
commit b61b2a37b7
2 changed files with 7 additions and 0 deletions

View File

@ -35,6 +35,7 @@
#include "absl/strings/str_join.h"
#include "absl/strings/str_split.h"
#include "absl/strings/string_view.h"
#include "absl/synchronization/mutex.h"
#include "sandboxed_api/embed_file.h"
#include "sandboxed_api/sandbox2/comms.h"
#include "sandboxed_api/sandbox2/fork_client.h"
@ -206,4 +207,9 @@ pid_t GlobalForkClient::GetPid() {
EnsureStartedLocked(GlobalForkserverStartMode::kOnDemand);
return instance_->fork_client_.pid();
}
bool GlobalForkClient::IsStarted() {
absl::ReaderMutexLock lock(&instance_mutex_);
return instance_ != nullptr;
}
} // namespace sandbox2

View File

@ -54,6 +54,7 @@ class GlobalForkClient {
EnsureStarted(GlobalForkserverStartMode::kOnDemand);
}
static void Shutdown() ABSL_LOCKS_EXCLUDED(instance_mutex_);
static bool IsStarted() ABSL_LOCKS_EXCLUDED(instance_mutex_);
private:
friend void StartGlobalForkserverFromLibCtor();