X-Git-Url: https://gerrit.akraino.org/r/gitweb?a=blobdiff_plain;f=src%2Ftype3_AndroidCloud%2Fanbox-master%2Fexternal%2Fprocess-cpp-minimal%2Finclude%2Fcore%2Fposix%2Fsignal.h;fp=src%2Ftype3_AndroidCloud%2Fanbox-master%2Fexternal%2Fprocess-cpp-minimal%2Finclude%2Fcore%2Fposix%2Fsignal.h;h=d11724af5eb8067e57002e07fa1ceaef82733eba;hb=e26c1ec581be598521517829adba8c8dd23a768f;hp=0000000000000000000000000000000000000000;hpb=6699c1aea74eeb0eb400e6299079f0c7576f716f;p=iec.git diff --git a/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/signal.h b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/signal.h new file mode 100644 index 0000000..d11724a --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/signal.h @@ -0,0 +1,117 @@ +/* + * Copyright © 2013 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Authored by: Thomas Voß + */ + +#ifndef CORE_POSIX_SIGNAL_H_ +#define CORE_POSIX_SIGNAL_H_ + +#include + +#include + +#include + +#include +#include + +namespace core +{ +namespace posix +{ +/** + * @brief The Signal enum collects the most common POSIX signals. + */ +enum class Signal +{ + unknown = 0, + sig_hup = SIGHUP, + sig_int = SIGINT, + sig_quit = SIGQUIT, + sig_ill = SIGILL, + sig_abrt = SIGABRT, + sig_fpe = SIGFPE, + sig_kill = SIGKILL, + sig_segv = SIGSEGV, + sig_pipe = SIGPIPE, + sig_alrm = SIGALRM, + sig_term = SIGTERM, + sig_usr1 = SIGUSR1, + sig_usr2 = SIGUSR2, + sig_chld = SIGCHLD, + sig_cont = SIGCONT, + sig_stop = SIGSTOP, + sig_tstp = SIGTSTP, + sig_ttin = SIGTTIN, + sig_ttou = SIGTTOU +}; + +/** + * @brief The SignalTrap class encapsulates functionality to trap and handle signals. + */ +class CORE_POSIX_DLL_PUBLIC SignalTrap +{ +public: + SignalTrap(const SignalTrap&) = delete; + virtual ~SignalTrap() = default; + + SignalTrap& operator=(const SignalTrap&) = delete; + bool operator==(const SignalTrap&) const = delete; + + /** + * @brief Returns true if the given signal is trapped by this instance. + */ + virtual bool has(Signal signal) = 0; + + /** + * @brief Starts observation of incoming signals, relaying them via + * signal_raised(). The call blocks until stop is called. + */ + virtual void run() = 0; + + /** + * @brief Stops execution of the signal trap. + */ + virtual void stop() = 0; + + /** + * @brief Emitted whenever a trapped signal is raised by the operating system. + */ + virtual core::Signal& signal_raised() = 0; + +protected: + SignalTrap() = default; +}; + +/** + * @brief Traps the specified signals for the entire process. + */ +CORE_POSIX_DLL_PUBLIC +std::shared_ptr trap_signals_for_process( + std::initializer_list blocked_signals); + +/** + * @brief Traps the specified signals for the current thread, and inherits + * the respective signal mask to all child-threads. + */ +CORE_POSIX_DLL_PUBLIC +std::shared_ptr trap_signals_for_all_subsequent_threads( + std::initializer_list blocked_signals); + +} +} + +#endif