2015-04-13 04:09:02 -05:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
|
2015-03-17 18:56:15 -05:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*/
|
|
|
|
|
2015-12-13 11:04:45 -06:00
|
|
|
#include <sys/poll.h>
|
2015-12-30 10:41:41 -06:00
|
|
|
#ifdef __linux
|
|
|
|
#include <sys/prctl.h>
|
|
|
|
#endif
|
2015-12-13 11:04:45 -06:00
|
|
|
|
2015-03-28 06:53:44 -05:00
|
|
|
#include <cstdlib>
|
2015-04-09 17:25:48 -05:00
|
|
|
#include <cstring>
|
2015-11-06 04:46:31 -06:00
|
|
|
#include <iomanip>
|
|
|
|
#include <sstream>
|
2015-03-17 18:56:15 -05:00
|
|
|
#include <string>
|
2015-11-24 02:19:17 -06:00
|
|
|
#include <cassert>
|
2015-12-19 08:16:44 -06:00
|
|
|
#include <random>
|
|
|
|
#include <mutex>
|
2015-03-17 18:56:15 -05:00
|
|
|
|
2015-03-28 06:53:44 -05:00
|
|
|
#include <png.h>
|
|
|
|
|
2015-04-24 04:49:19 -05:00
|
|
|
#include <signal.h>
|
|
|
|
|
2015-04-22 03:14:11 -05:00
|
|
|
#include <Poco/Exception.h>
|
2015-04-27 06:16:37 -05:00
|
|
|
#include <Poco/Format.h>
|
2015-04-22 03:14:11 -05:00
|
|
|
#include <Poco/Net/WebSocket.h>
|
2015-03-17 18:56:15 -05:00
|
|
|
#include <Poco/Process.h>
|
2015-04-27 06:16:37 -05:00
|
|
|
#include <Poco/Timestamp.h>
|
2015-03-17 18:56:15 -05:00
|
|
|
#include <Poco/Thread.h>
|
2015-04-22 03:14:11 -05:00
|
|
|
#include <Poco/Util/Application.h>
|
2015-12-23 15:58:38 -06:00
|
|
|
#include <Poco/Environment.h>
|
2015-12-24 21:19:50 -06:00
|
|
|
#include <Poco/ConsoleChannel.h>
|
2015-03-17 18:56:15 -05:00
|
|
|
|
2016-01-09 12:51:55 -06:00
|
|
|
#include <Common.hpp>
|
2015-03-17 18:56:15 -05:00
|
|
|
#include "Util.hpp"
|
2015-11-20 09:39:44 -06:00
|
|
|
#include "Png.hpp"
|
2015-03-17 18:56:15 -05:00
|
|
|
|
2015-03-28 06:53:44 -05:00
|
|
|
// Callback functions for libpng
|
|
|
|
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
static void user_write_status_fn(png_structp, png_uint_32, int)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void user_write_fn(png_structp png_ptr, png_bytep data, png_size_t length)
|
|
|
|
{
|
|
|
|
std::vector<char> *outputp = (std::vector<char> *) png_get_io_ptr(png_ptr);
|
2016-01-07 08:40:41 -06:00
|
|
|
const size_t oldsize = outputp->size();
|
2015-03-28 06:53:44 -05:00
|
|
|
outputp->resize(oldsize + length);
|
|
|
|
memcpy(outputp->data() + oldsize, data, length);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void user_flush_fn(png_structp)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-09 12:51:55 -06:00
|
|
|
volatile LOOLState TerminationState = LOOLState::LOOL_RUNNING;
|
|
|
|
volatile bool TerminationFlag = false;
|
|
|
|
|
2015-12-19 08:16:44 -06:00
|
|
|
namespace Util
|
|
|
|
{
|
|
|
|
namespace rng
|
|
|
|
{
|
|
|
|
static std::random_device _rd;
|
|
|
|
static std::mutex _rngMutex;
|
|
|
|
static std::mt19937_64 _rng = std::mt19937_64(_rd());
|
|
|
|
unsigned getNext()
|
|
|
|
{
|
|
|
|
std::unique_lock<std::mutex> lock(_rngMutex);
|
|
|
|
return _rng();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-20 11:59:26 -06:00
|
|
|
namespace Log
|
|
|
|
{
|
2015-12-27 14:15:57 -06:00
|
|
|
static const Poco::Int64 epochStart = Poco::Timestamp().epochMicroseconds();
|
2015-12-24 21:19:50 -06:00
|
|
|
static std::string SourceName;
|
|
|
|
static std::string SourceId;
|
2015-12-20 11:59:26 -06:00
|
|
|
|
2015-12-27 14:15:57 -06:00
|
|
|
std::string logPrefix()
|
|
|
|
{
|
|
|
|
Poco::Int64 usec = Poco::Timestamp().epochMicroseconds() - epochStart;
|
|
|
|
|
|
|
|
const Poco::Int64 one_s = 1000000;
|
|
|
|
const Poco::Int64 hours = usec / (one_s*60*60);
|
|
|
|
usec %= (one_s*60*60);
|
|
|
|
const Poco::Int64 minutes = usec / (one_s*60);
|
|
|
|
usec %= (one_s*60);
|
|
|
|
const Poco::Int64 seconds = usec / (one_s);
|
|
|
|
usec %= (one_s);
|
|
|
|
|
|
|
|
std::ostringstream stream;
|
|
|
|
stream << Log::SourceId << '-' << std::setw(2) << std::setfill('0')
|
2016-01-13 08:34:43 -06:00
|
|
|
<< (Poco::Thread::current() ? Poco::Thread::current()->id() : 0) << ' '
|
2015-12-27 14:15:57 -06:00
|
|
|
<< std::setw(2) << hours << ':' << std::setw(2) << minutes << ':'
|
|
|
|
<< std::setw(2) << seconds << "." << std::setw(6) << usec
|
2016-01-13 08:34:43 -06:00
|
|
|
<< ' ';
|
2015-12-27 14:15:57 -06:00
|
|
|
|
2015-12-30 10:41:41 -06:00
|
|
|
#ifdef __linux
|
|
|
|
char buf[32]; // we really need only 16
|
|
|
|
if (prctl(PR_GET_NAME, reinterpret_cast<unsigned long>(buf), 0, 0, 0) == 0)
|
2016-01-13 08:34:43 -06:00
|
|
|
stream << '[' << std::setw(15) << std::setfill(' ') << std::left << buf << "] ";
|
2015-12-30 10:41:41 -06:00
|
|
|
#endif
|
|
|
|
|
2015-12-27 14:15:57 -06:00
|
|
|
return stream.str();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-12-20 11:59:26 -06:00
|
|
|
void initialize(const std::string& name)
|
|
|
|
{
|
2015-12-24 21:19:50 -06:00
|
|
|
SourceName = name;
|
|
|
|
std::ostringstream oss;
|
|
|
|
oss << SourceName << '-'
|
|
|
|
<< std::setw(5) << std::setfill('0') << Poco::Process::id();
|
|
|
|
SourceId = oss.str();
|
|
|
|
|
|
|
|
auto& logger = Poco::Logger::create(SourceName, new Poco::ColorConsoleChannel(), Poco::Message::PRIO_INFORMATION);
|
2015-12-23 15:58:38 -06:00
|
|
|
|
|
|
|
// Configure the logger.
|
|
|
|
// TODO: This should come from a file.
|
|
|
|
try
|
|
|
|
{
|
|
|
|
// See Poco::Logger::setLevel docs for values.
|
|
|
|
// Try: error, information, debug
|
|
|
|
const auto level = Poco::Environment::get("LOOL_LOGLEVEL");
|
|
|
|
logger.setLevel(level);
|
|
|
|
}
|
|
|
|
catch (Poco::NotFoundException& aError)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-12-24 21:19:50 -06:00
|
|
|
info("Initializing " + name);
|
|
|
|
info("Log level is [" + std::to_string(logger.getLevel()) + "].");
|
2015-12-20 11:59:26 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
Poco::Logger& logger()
|
|
|
|
{
|
2015-12-24 21:19:50 -06:00
|
|
|
return Poco::Logger::get(SourceName);
|
|
|
|
}
|
|
|
|
|
|
|
|
void trace(const std::string& msg)
|
|
|
|
{
|
2015-12-27 14:15:57 -06:00
|
|
|
logger().trace(logPrefix() + msg);
|
2015-12-20 11:59:26 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void debug(const std::string& msg)
|
|
|
|
{
|
2015-12-27 14:15:57 -06:00
|
|
|
logger().debug(logPrefix() + msg);
|
2015-12-20 11:59:26 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void info(const std::string& msg)
|
|
|
|
{
|
2015-12-27 14:15:57 -06:00
|
|
|
logger().information(logPrefix() + msg);
|
2015-12-20 11:59:26 -06:00
|
|
|
}
|
|
|
|
|
2016-01-13 08:34:43 -06:00
|
|
|
void warn(const std::string& msg, const bool append_errno)
|
2015-12-23 15:58:38 -06:00
|
|
|
{
|
2016-01-13 08:34:43 -06:00
|
|
|
logger().warning(logPrefix() + msg +
|
|
|
|
(append_errno
|
|
|
|
? (std::string(" (errno: ") + strerror(errno) + ").")
|
|
|
|
: std::string(".")));
|
2015-12-23 15:58:38 -06:00
|
|
|
}
|
|
|
|
|
2016-01-13 08:34:43 -06:00
|
|
|
void error(const std::string& msg, const bool append_errno)
|
2015-12-20 11:59:26 -06:00
|
|
|
{
|
2016-01-13 08:34:43 -06:00
|
|
|
logger().error(logPrefix() + msg +
|
|
|
|
(append_errno
|
|
|
|
? (std::string(" (errno: ") + strerror(errno) + ").")
|
|
|
|
: std::string(".")));
|
2015-12-20 11:59:26 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-26 10:07:52 -05:00
|
|
|
namespace Util
|
2015-03-17 18:56:15 -05:00
|
|
|
{
|
2015-12-27 21:47:39 -06:00
|
|
|
std::string encodeId(const unsigned number, const int padding)
|
|
|
|
{
|
|
|
|
std::ostringstream oss;
|
|
|
|
oss << std::hex << std::setw(padding) << std::setfill('0') << number;
|
|
|
|
return oss.str();
|
|
|
|
}
|
|
|
|
|
2016-01-09 14:46:08 -06:00
|
|
|
unsigned decodeId(const std::string& str)
|
|
|
|
{
|
|
|
|
unsigned id = 0;
|
|
|
|
std::stringstream ss;
|
|
|
|
ss << std::hex << str;
|
|
|
|
ss >> id;
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
2016-01-06 21:47:01 -06:00
|
|
|
std::string createRandomDir(const std::string& path)
|
|
|
|
{
|
|
|
|
Poco::File(path).createDirectories();
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
const auto name = Util::encodeId(rng::getNext());
|
|
|
|
Poco::File dir(Poco::Path(path, name));
|
|
|
|
if (dir.createDirectory())
|
|
|
|
{
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string createRandomFile(const std::string& path)
|
|
|
|
{
|
|
|
|
Poco::File(path).createDirectories();
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
const auto name = Util::encodeId(rng::getNext());
|
|
|
|
Poco::File file(Poco::Path(path, name));
|
|
|
|
if (file.createFile())
|
|
|
|
{
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-28 06:53:44 -05:00
|
|
|
bool windowingAvailable()
|
|
|
|
{
|
|
|
|
#ifdef __linux
|
2015-12-29 19:34:53 -06:00
|
|
|
return std::getenv("DISPLAY") != nullptr;
|
2015-03-28 06:53:44 -05:00
|
|
|
#endif
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-01-12 05:00:42 -06:00
|
|
|
bool encodeBufferToPNG(unsigned char *pixmap, int width, int height, std::vector<char>& output, LibreOfficeKitTileMode mode)
|
2015-03-28 06:53:44 -05:00
|
|
|
{
|
2016-01-12 05:00:42 -06:00
|
|
|
|
|
|
|
return encodeSubBufferToPNG(pixmap, 0, 0, width, height, width, height, output, mode);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool encodeSubBufferToPNG(unsigned char *pixmap, int startX, int startY, int width, int height,
|
|
|
|
int bufferWidth, int bufferHeight, std::vector<char>& output, LibreOfficeKitTileMode mode)
|
|
|
|
{
|
|
|
|
if (bufferWidth < width || bufferHeight < height)
|
|
|
|
return false;
|
|
|
|
|
2015-12-29 19:34:53 -06:00
|
|
|
png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr);
|
2015-03-28 06:53:44 -05:00
|
|
|
|
|
|
|
png_infop info_ptr = png_create_info_struct(png_ptr);
|
|
|
|
|
|
|
|
if (setjmp(png_jmpbuf(png_ptr)))
|
|
|
|
{
|
2015-12-29 19:34:53 -06:00
|
|
|
png_destroy_write_struct(&png_ptr, nullptr);
|
2015-03-28 06:53:44 -05:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
png_set_IHDR(png_ptr, info_ptr, width, height, 8, PNG_COLOR_TYPE_RGB_ALPHA, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
|
|
|
|
|
|
|
|
png_set_write_fn(png_ptr, &output, user_write_fn, user_flush_fn);
|
|
|
|
png_set_write_status_fn(png_ptr, user_write_status_fn);
|
|
|
|
|
|
|
|
png_write_info(png_ptr, info_ptr);
|
|
|
|
|
2016-01-12 05:00:42 -06:00
|
|
|
if (mode == LOK_TILEMODE_BGRA)
|
2015-11-24 02:19:17 -06:00
|
|
|
{
|
|
|
|
png_set_write_user_transform_fn (png_ptr, unpremultiply_data);
|
|
|
|
}
|
|
|
|
|
2015-03-28 06:53:44 -05:00
|
|
|
for (int y = 0; y < height; ++y)
|
2016-01-12 05:00:42 -06:00
|
|
|
{
|
|
|
|
size_t position = ((startY + y) * bufferWidth * 4) + (startX * 4);
|
|
|
|
png_write_row(png_ptr, pixmap + position);
|
|
|
|
}
|
2015-03-28 06:53:44 -05:00
|
|
|
|
|
|
|
png_write_end(png_ptr, info_ptr);
|
|
|
|
|
2015-11-20 09:43:09 -06:00
|
|
|
png_destroy_write_struct(&png_ptr, &info_ptr);
|
2015-03-28 06:53:44 -05:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2015-04-22 03:14:11 -05:00
|
|
|
|
|
|
|
void shutdownWebSocket(Poco::Net::WebSocket& ws)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
ws.shutdown();
|
|
|
|
}
|
2015-12-25 12:50:53 -06:00
|
|
|
catch (const Poco::IOException& exc)
|
2015-04-22 03:14:11 -05:00
|
|
|
{
|
2015-12-27 14:15:57 -06:00
|
|
|
Log::error("IOException: " + exc.message());
|
2015-04-22 03:14:11 -05:00
|
|
|
}
|
|
|
|
}
|
2015-04-24 04:49:19 -05:00
|
|
|
|
2016-01-13 08:34:43 -06:00
|
|
|
std::string signalName(const int signo)
|
2015-04-24 04:49:19 -05:00
|
|
|
{
|
|
|
|
switch (signo)
|
|
|
|
{
|
|
|
|
#define CASE(x) case SIG##x: return #x
|
|
|
|
CASE(HUP);
|
|
|
|
CASE(INT);
|
|
|
|
CASE(QUIT);
|
|
|
|
CASE(ILL);
|
|
|
|
CASE(ABRT);
|
|
|
|
CASE(FPE);
|
|
|
|
CASE(KILL);
|
|
|
|
CASE(SEGV);
|
2015-05-04 12:52:28 -05:00
|
|
|
CASE(PIPE);
|
2015-04-24 04:49:19 -05:00
|
|
|
CASE(ALRM);
|
|
|
|
CASE(TERM);
|
|
|
|
CASE(USR1);
|
|
|
|
CASE(USR2);
|
|
|
|
CASE(CHLD);
|
|
|
|
CASE(CONT);
|
|
|
|
CASE(STOP);
|
|
|
|
CASE(TSTP);
|
|
|
|
CASE(TTIN);
|
|
|
|
CASE(TTOU);
|
|
|
|
CASE(BUS);
|
2015-05-04 12:52:28 -05:00
|
|
|
#ifdef SIGPOLL
|
2015-04-24 04:49:19 -05:00
|
|
|
CASE(POLL);
|
2015-05-04 12:52:28 -05:00
|
|
|
#endif
|
2015-04-24 04:49:19 -05:00
|
|
|
CASE(PROF);
|
|
|
|
CASE(SYS);
|
|
|
|
CASE(TRAP);
|
|
|
|
CASE(URG);
|
|
|
|
CASE(VTALRM);
|
|
|
|
CASE(XCPU);
|
|
|
|
CASE(XFSZ);
|
|
|
|
#ifdef SIGEMT
|
|
|
|
CASE(EMT);
|
|
|
|
#endif
|
2015-05-04 12:52:28 -05:00
|
|
|
#ifdef SIGSTKFLT
|
2015-04-24 04:49:19 -05:00
|
|
|
CASE(STKFLT);
|
2015-05-04 12:52:28 -05:00
|
|
|
#endif
|
2015-04-24 04:49:19 -05:00
|
|
|
#if defined(SIGIO) && SIGIO != SIGPOLL
|
|
|
|
CASE(IO);
|
|
|
|
#endif
|
|
|
|
#ifdef SIGPWR
|
|
|
|
CASE(PWR);
|
|
|
|
#endif
|
|
|
|
#ifdef SIGLOST
|
|
|
|
CASE(LOST);
|
|
|
|
#endif
|
|
|
|
CASE(WINCH);
|
2015-05-04 12:52:28 -05:00
|
|
|
#if defined(SIGINFO) && SIGINFO != SIGPWR
|
|
|
|
CASE(INFO);
|
|
|
|
#endif
|
2015-04-24 04:49:19 -05:00
|
|
|
#undef CASE
|
|
|
|
default:
|
|
|
|
return std::to_string(signo);
|
|
|
|
}
|
|
|
|
}
|
2015-12-13 11:04:45 -06:00
|
|
|
|
|
|
|
ssize_t writeFIFO(int nPipe, const char* pBuffer, ssize_t nSize)
|
|
|
|
{
|
|
|
|
ssize_t nBytes = -1;
|
|
|
|
ssize_t nCount = 0;
|
|
|
|
|
|
|
|
while(true)
|
|
|
|
{
|
|
|
|
nBytes = write(nPipe, pBuffer + nCount, nSize - nCount);
|
|
|
|
if (nBytes < 0)
|
|
|
|
{
|
|
|
|
if (errno == EINTR || errno == EAGAIN)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
nCount = -1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if ( nCount + nBytes < nSize )
|
|
|
|
{
|
|
|
|
nCount += nBytes;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
nCount = nBytes;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
ssize_t readFIFO(int nPipe, char* pBuffer, ssize_t nSize)
|
|
|
|
{
|
|
|
|
ssize_t nBytes;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
nBytes = read(nPipe, pBuffer, nSize);
|
|
|
|
}
|
|
|
|
while ( nBytes < 0 && errno == EINTR );
|
|
|
|
|
|
|
|
return nBytes;
|
|
|
|
}
|
|
|
|
|
|
|
|
ssize_t readMessage(int nPipe, char* pBuffer, ssize_t nSize)
|
|
|
|
{
|
|
|
|
ssize_t nBytes = -1;
|
|
|
|
struct pollfd aPoll;
|
|
|
|
|
|
|
|
aPoll.fd = nPipe;
|
|
|
|
aPoll.events = POLLIN;
|
|
|
|
aPoll.revents = 0;
|
|
|
|
|
2016-01-13 18:28:51 -06:00
|
|
|
const int nPoll = poll(&aPoll, 1, CHILD_TIMEOUT_SECS * 1000);
|
2015-12-13 11:04:45 -06:00
|
|
|
if ( nPoll < 0 )
|
2016-01-13 18:28:51 -06:00
|
|
|
return -1;
|
2015-12-13 11:04:45 -06:00
|
|
|
|
|
|
|
if ( nPoll == 0 )
|
|
|
|
errno = ETIME;
|
|
|
|
|
|
|
|
if( (aPoll.revents & POLLIN) != 0 )
|
|
|
|
nBytes = readFIFO(nPipe, pBuffer, nSize);
|
|
|
|
|
|
|
|
return nBytes;
|
|
|
|
}
|
2016-01-09 12:51:55 -06:00
|
|
|
|
|
|
|
static
|
|
|
|
void handleSignal(int aSignal)
|
|
|
|
{
|
|
|
|
Log::info() << "Signal received: " << strsignal(aSignal) << Log::end;
|
|
|
|
TerminationFlag = true;
|
|
|
|
TerminationState = ( aSignal == SIGTERM ? LOOLState::LOOL_ABNORMAL : LOOLState::LOOL_STOPPING );
|
|
|
|
|
|
|
|
if (aSignal == SIGSEGV || aSignal == SIGBUS)
|
|
|
|
{
|
|
|
|
Log::error() << "\nSegfault! Stalling for 10 seconds to attach debugger. Use:\n"
|
|
|
|
<< "sudo gdb --pid=" << Poco::Process::id() << "\n or \n"
|
|
|
|
<< "sudo gdb --q --n --ex 'thread apply all backtrace full' --batch --pid="
|
|
|
|
<< Poco::Process::id() << "\n" << Log::end;
|
|
|
|
sleep(10);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void setSignals(bool isIgnored)
|
|
|
|
{
|
|
|
|
#ifdef __linux
|
|
|
|
struct sigaction aSigAction;
|
|
|
|
|
|
|
|
sigemptyset(&aSigAction.sa_mask);
|
|
|
|
aSigAction.sa_flags = 0;
|
|
|
|
aSigAction.sa_handler = (isIgnored ? SIG_IGN : handleSignal);
|
|
|
|
|
|
|
|
sigaction(SIGTERM, &aSigAction, nullptr);
|
|
|
|
sigaction(SIGINT, &aSigAction, nullptr);
|
|
|
|
sigaction(SIGQUIT, &aSigAction, nullptr);
|
|
|
|
sigaction(SIGHUP, &aSigAction, nullptr);
|
2016-01-10 21:13:32 -06:00
|
|
|
|
|
|
|
if (getenv("LOOL_DEBUG"))
|
|
|
|
{
|
|
|
|
sigaction(SIGBUS, &aSigAction, nullptr);
|
|
|
|
sigaction(SIGSEGV, &aSigAction, nullptr);
|
|
|
|
}
|
2016-01-09 12:51:55 -06:00
|
|
|
#endif
|
|
|
|
}
|
2015-03-17 18:56:15 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|