diff options
author | orivej <orivej@yandex-team.ru> | 2022-02-10 16:45:01 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:01 +0300 |
commit | 2d37894b1b037cf24231090eda8589bbb44fb6fc (patch) | |
tree | be835aa92c6248212e705f25388ebafcf84bc7a1 /contrib/libs/poco/Foundation/src/SignalHandler.cpp | |
parent | 718c552901d703c502ccbefdfc3c9028d608b947 (diff) | |
download | ydb-2d37894b1b037cf24231090eda8589bbb44fb6fc.tar.gz |
Restoring authorship annotation for <orivej@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/libs/poco/Foundation/src/SignalHandler.cpp')
-rw-r--r-- | contrib/libs/poco/Foundation/src/SignalHandler.cpp | 222 |
1 files changed, 111 insertions, 111 deletions
diff --git a/contrib/libs/poco/Foundation/src/SignalHandler.cpp b/contrib/libs/poco/Foundation/src/SignalHandler.cpp index 4aca858367..eaa1dc7ec8 100644 --- a/contrib/libs/poco/Foundation/src/SignalHandler.cpp +++ b/contrib/libs/poco/Foundation/src/SignalHandler.cpp @@ -1,111 +1,111 @@ -// -// SignalHandler.cpp -// -// Library: Foundation -// Package: Threading -// Module: SignalHandler -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#include "Poco/SignalHandler.h" - - -#if defined(POCO_OS_FAMILY_UNIX) && !defined(POCO_VXWORKS) - - -#include "Poco/Thread.h" -#include "Poco/NumberFormatter.h" -#include "Poco/Exception.h" -#include <cstdlib> -#include <signal.h> - - -namespace Poco { - - -SignalHandler::JumpBufferVec SignalHandler::_jumpBufferVec; - - -SignalHandler::SignalHandler() -{ - JumpBufferVec& jbv = jumpBufferVec(); - JumpBuffer buf; - jbv.push_back(buf); -} - - -SignalHandler::~SignalHandler() -{ - jumpBufferVec().pop_back(); -} - - -sigjmp_buf& SignalHandler::jumpBuffer() -{ - return jumpBufferVec().back().buf; -} - - -void SignalHandler::throwSignalException(int sig) -{ - switch (sig) - { - case SIGILL: - throw SignalException("Illegal instruction"); - case SIGBUS: - throw SignalException("Bus error"); - case SIGSEGV: - throw SignalException("Segmentation violation"); - case SIGSYS: - throw SignalException("Invalid system call"); - default: - throw SignalException(NumberFormatter::formatHex(sig)); - } -} - - -void SignalHandler::install() -{ -#ifndef POCO_NO_SIGNAL_HANDLER - struct sigaction sa; - sa.sa_handler = handleSignal; - sa.sa_flags = 0; - sigemptyset(&sa.sa_mask); - sigaction(SIGILL, &sa, 0); - sigaction(SIGBUS, &sa, 0); - sigaction(SIGSEGV, &sa, 0); - sigaction(SIGSYS, &sa, 0); -#endif -} - - -void SignalHandler::handleSignal(int sig) -{ - JumpBufferVec& jb = jumpBufferVec(); - if (!jb.empty()) - siglongjmp(jb.back().buf, sig); - - // Abort if no jump buffer registered - std::abort(); -} - - -SignalHandler::JumpBufferVec& SignalHandler::jumpBufferVec() -{ - ThreadImpl* pThread = ThreadImpl::currentImpl(); - if (pThread) - return pThread->_jumpBufferVec; - else - return _jumpBufferVec; -} - - -} // namespace Poco - - -#endif // POCO_OS_FAMILY_UNIX +// +// SignalHandler.cpp +// +// Library: Foundation +// Package: Threading +// Module: SignalHandler +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#include "Poco/SignalHandler.h" + + +#if defined(POCO_OS_FAMILY_UNIX) && !defined(POCO_VXWORKS) + + +#include "Poco/Thread.h" +#include "Poco/NumberFormatter.h" +#include "Poco/Exception.h" +#include <cstdlib> +#include <signal.h> + + +namespace Poco { + + +SignalHandler::JumpBufferVec SignalHandler::_jumpBufferVec; + + +SignalHandler::SignalHandler() +{ + JumpBufferVec& jbv = jumpBufferVec(); + JumpBuffer buf; + jbv.push_back(buf); +} + + +SignalHandler::~SignalHandler() +{ + jumpBufferVec().pop_back(); +} + + +sigjmp_buf& SignalHandler::jumpBuffer() +{ + return jumpBufferVec().back().buf; +} + + +void SignalHandler::throwSignalException(int sig) +{ + switch (sig) + { + case SIGILL: + throw SignalException("Illegal instruction"); + case SIGBUS: + throw SignalException("Bus error"); + case SIGSEGV: + throw SignalException("Segmentation violation"); + case SIGSYS: + throw SignalException("Invalid system call"); + default: + throw SignalException(NumberFormatter::formatHex(sig)); + } +} + + +void SignalHandler::install() +{ +#ifndef POCO_NO_SIGNAL_HANDLER + struct sigaction sa; + sa.sa_handler = handleSignal; + sa.sa_flags = 0; + sigemptyset(&sa.sa_mask); + sigaction(SIGILL, &sa, 0); + sigaction(SIGBUS, &sa, 0); + sigaction(SIGSEGV, &sa, 0); + sigaction(SIGSYS, &sa, 0); +#endif +} + + +void SignalHandler::handleSignal(int sig) +{ + JumpBufferVec& jb = jumpBufferVec(); + if (!jb.empty()) + siglongjmp(jb.back().buf, sig); + + // Abort if no jump buffer registered + std::abort(); +} + + +SignalHandler::JumpBufferVec& SignalHandler::jumpBufferVec() +{ + ThreadImpl* pThread = ThreadImpl::currentImpl(); + if (pThread) + return pThread->_jumpBufferVec; + else + return _jumpBufferVec; +} + + +} // namespace Poco + + +#endif // POCO_OS_FAMILY_UNIX |