#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "chrome/browser/shutdown_signal_handlers_posix.h"
#include <limits.h>
#include <signal.h>
#include <string.h>
#include <unistd.h>
#include <utility>
#include "base/debug/leak_annotations.h"
#include "base/functional/callback.h"
#include "base/logging.h"
#include "base/posix/eintr_wrapper.h"
#include "base/task/single_thread_task_runner.h"
#include "base/threading/platform_thread.h"
namespace {
pid_t g_pipe_pid = …;
int g_shutdown_pipe_write_fd = …;
int g_shutdown_pipe_read_fd = …;
void GracefulShutdownHandler(int signal) { … }
void SIGHUPHandler(int signal) { … }
void SIGINTHandler(int signal) { … }
void SIGTERMHandler(int signal) { … }
class ShutdownDetector : public base::PlatformThread::Delegate { … };
ShutdownDetector::ShutdownDetector(
int shutdown_fd,
base::OnceCallback<void(int)> shutdown_callback,
const scoped_refptr<base::SingleThreadTaskRunner>& task_runner)
: … { … }
ShutdownDetector::~ShutdownDetector() { … }
NOINLINE void ShutdownFDReadError() { … }
NOINLINE void ShutdownFDClosedError() { … }
NOINLINE void ExitPosted() { … }
void ShutdownDetector::ThreadMain() { … }
}
void InstallShutdownSignalHandlers(
base::OnceCallback<void(int)> shutdown_callback,
const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) { … }