blob: a475e457c629d9aec8afd99a33e09a352e4a98c6 [file] [log] [blame]
Brian Silvermanf5f8d8e2015-12-06 18:39:12 -05001#include "aos/testing/prevent_exit.h"
2
Brian Silvermanf5f8d8e2015-12-06 18:39:12 -05003#include <unistd.h>
4
Tyler Chatowbf0609c2021-07-31 16:13:27 -07005#include <cstdlib>
6
Austin Schuh99f7c6a2024-06-25 22:07:44 -07007#include "absl/log/check.h"
8#include "absl/log/log.h"
Brian Silvermanf5f8d8e2015-12-06 18:39:12 -05009
Stephan Pleinesf63bde82024-01-13 15:59:33 -080010namespace aos::testing {
Brian Silvermanf5f8d8e2015-12-06 18:39:12 -050011namespace {
12
Tyler Chatowbf0609c2021-07-31 16:13:27 -070013void TerminateExitHandler() { _exit(EXIT_SUCCESS); }
Brian Silvermanf5f8d8e2015-12-06 18:39:12 -050014
15} // namespace
16
Tyler Chatowbf0609c2021-07-31 16:13:27 -070017void PreventExit() { CHECK_EQ(atexit(TerminateExitHandler), 0); }
Brian Silvermanf5f8d8e2015-12-06 18:39:12 -050018
Stephan Pleinesf63bde82024-01-13 15:59:33 -080019} // namespace aos::testing