mirror of
https://github.com/google/sandboxed-api.git
synced 2024-03-22 13:11:30 +08:00
Wait for global forkserver when shutting it down
Otherwise starting forkserver multiple times will result in zombie processes lingering around. PiperOrigin-RevId: 388926497 Change-Id: Ia9947cce3d9e909edd709b0d3525e1ae8b8bbc51
This commit is contained in:
parent
e88755256d
commit
fe709502f4
|
@ -19,6 +19,8 @@
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <sys/prctl.h>
|
#include <sys/prctl.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
#include <syscall.h>
|
#include <syscall.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
@ -192,10 +194,22 @@ void GlobalForkClient::ForceStart() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlobalForkClient::Shutdown() {
|
void GlobalForkClient::Shutdown() {
|
||||||
|
pid_t pid = -1;
|
||||||
|
{
|
||||||
absl::MutexLock lock(&GlobalForkClient::instance_mutex_);
|
absl::MutexLock lock(&GlobalForkClient::instance_mutex_);
|
||||||
|
if (instance_) {
|
||||||
|
pid = instance_->fork_client_.pid();
|
||||||
|
}
|
||||||
delete instance_;
|
delete instance_;
|
||||||
instance_ = nullptr;
|
instance_ = nullptr;
|
||||||
}
|
}
|
||||||
|
if (pid != -1) {
|
||||||
|
pid_t wpid = TEMP_FAILURE_RETRY(waitpid(pid, nullptr, 0));
|
||||||
|
if (wpid != pid) {
|
||||||
|
SAPI_RAW_PLOG(ERROR, "Waiting for %d failed", pid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pid_t GlobalForkClient::SendRequest(const ForkRequest& request, int exec_fd,
|
pid_t GlobalForkClient::SendRequest(const ForkRequest& request, int exec_fd,
|
||||||
int comms_fd, int user_ns_fd,
|
int comms_fd, int user_ns_fd,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user