Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed signal handling. #22

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 0 additions & 52 deletions src/Spawner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,68 +15,16 @@
#include <boost/filesystem.hpp>
#include "CorbaNameService.hpp"
#include <lib_config/Bundle.hpp>
#include <signal.h>
#include <backward/backward.hpp>
#include <rtt/transports/corba/TaskContextProxy.hpp>

using namespace orocos_cpp;
using namespace libConfig;

struct sigaction originalSignalHandler[SIGTERM + 1];

backward::SignalHandling sh;

void shutdownHandler(int signum, siginfo_t *info, void *data);

void restoreSignalHandler(int signum)
{
if(sigaction(signum, originalSignalHandler + signum, nullptr))
{
throw std::runtime_error("Error, failed to reregister original signal handler");
}
}

void setSignalHandler(int signum)
{
struct sigaction act;

act.sa_sigaction = shutdownHandler;

/* The SA_SIGINFO flag tells sigaction() to use the sa_sigaction field, not sa_handler. */
act.sa_flags = SA_SIGINFO;

if(sigaction(signum, &act, originalSignalHandler + signum))
{
throw std::runtime_error("Error, failed to register signal handler");
}
}

void shutdownHandler(int signum, siginfo_t *info, void *data)
{
std::cout << "Shutdown: trying to kill all childs" << std::endl;

try {
Spawner::getInstace().killAll();
std::cout << "Done " << std::endl;
} catch (...)
{
std::cout << "Error, during killall" << std::endl;
}
restoreSignalHandler(signum);
raise(signum);

}

Spawner::Spawner()
{
nameService = new CorbaNameService();
nameService->connect();

setSignalHandler(SIGINT);
setSignalHandler(SIGQUIT);
setSignalHandler(SIGABRT);
setSignalHandler(SIGSEGV);
setSignalHandler(SIGTERM);
}

Spawner& Spawner::getInstace()
Expand Down