mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
* Print stack trace on crash * Printing stack trace is fully functional except for WIN32 * Minor fixes * Minor fixes
This commit is contained in:
@@ -12,6 +12,8 @@
|
||||
// ssdp discover
|
||||
#include <ssdp/SSDPDiscover.h>
|
||||
|
||||
#include <utils/DefaultSignalHandler.h>
|
||||
|
||||
using namespace commandline;
|
||||
|
||||
// save the image as screenshot
|
||||
@@ -29,6 +31,8 @@ int main(int argc, char ** argv)
|
||||
<< "\tVersion : " << HYPERION_VERSION << " (" << HYPERION_BUILD_ID << ")" << std::endl
|
||||
<< "\tbuild time: " << __DATE__ << " " << __TIME__ << std::endl;
|
||||
|
||||
DefaultSignalHandler::install();
|
||||
|
||||
QCoreApplication app(argc, argv);
|
||||
|
||||
try
|
||||
|
@@ -12,6 +12,8 @@
|
||||
// ssdp discover
|
||||
#include <ssdp/SSDPDiscover.h>
|
||||
|
||||
#include <utils/DefaultSignalHandler.h>
|
||||
|
||||
using namespace commandline;
|
||||
|
||||
// save the image as screenshot
|
||||
@@ -29,6 +31,8 @@ int main(int argc, char ** argv)
|
||||
<< "\tVersion : " << HYPERION_VERSION << " (" << HYPERION_BUILD_ID << ")" << std::endl
|
||||
<< "\tbuild time: " << __DATE__ << " " << __TIME__ << std::endl;
|
||||
|
||||
DefaultSignalHandler::install();
|
||||
|
||||
QCoreApplication app(argc, argv);
|
||||
|
||||
try
|
||||
|
@@ -9,6 +9,8 @@
|
||||
// ssdp discover
|
||||
#include <ssdp/SSDPDiscover.h>
|
||||
|
||||
#include <utils/DefaultSignalHandler.h>
|
||||
|
||||
using namespace commandline;
|
||||
|
||||
// save the image as screenshot
|
||||
@@ -21,6 +23,8 @@ void saveScreenshot(QString filename, const Image<ColorRgb> & image)
|
||||
|
||||
int main(int argc, char ** argv)
|
||||
{
|
||||
DefaultSignalHandler::install();
|
||||
|
||||
QCoreApplication app(argc, argv);
|
||||
|
||||
try
|
||||
|
@@ -11,6 +11,8 @@
|
||||
// ssdp discover
|
||||
#include <ssdp/SSDPDiscover.h>
|
||||
|
||||
#include <utils/DefaultSignalHandler.h>
|
||||
|
||||
using namespace commandline;
|
||||
|
||||
// save the image as screenshot
|
||||
@@ -23,6 +25,8 @@ void saveScreenshot(QString filename, const Image<ColorRgb> & image)
|
||||
|
||||
int main(int argc, char ** argv)
|
||||
{
|
||||
DefaultSignalHandler::install();
|
||||
|
||||
QCoreApplication app(argc, argv);
|
||||
|
||||
try
|
||||
|
@@ -17,6 +17,7 @@
|
||||
|
||||
#include "HyperionConfig.h"
|
||||
#include <commandline/Parser.h>
|
||||
#include <utils/DefaultSignalHandler.h>
|
||||
|
||||
using namespace commandline;
|
||||
|
||||
@@ -66,6 +67,8 @@ int main(int argc, char * argv[])
|
||||
<< "\tVersion : " << HYPERION_VERSION << " (" << HYPERION_BUILD_ID << ")" << std::endl
|
||||
<< "\tbuild time: " << __DATE__ << " " << __TIME__ << std::endl;
|
||||
|
||||
DefaultSignalHandler::install();
|
||||
|
||||
QCoreApplication app(argc, argv);
|
||||
|
||||
// force the locale
|
||||
|
@@ -24,6 +24,8 @@
|
||||
// ssdp discover
|
||||
#include <ssdp/SSDPDiscover.h>
|
||||
|
||||
#include <utils/DefaultSignalHandler.h>
|
||||
|
||||
using namespace commandline;
|
||||
|
||||
int main(int argc, char** argv)
|
||||
|
@@ -5,6 +5,7 @@
|
||||
|
||||
#include <commandline/Parser.h>
|
||||
#include <flatbufserver/FlatBufferConnection.h>
|
||||
#include <utils/DefaultSignalHandler.h>
|
||||
#include "X11Wrapper.h"
|
||||
#include "HyperionConfig.h"
|
||||
|
||||
@@ -28,6 +29,8 @@ int main(int argc, char ** argv)
|
||||
<< "\tVersion : " << HYPERION_VERSION << " (" << HYPERION_BUILD_ID << ")" << std::endl
|
||||
<< "\tbuild time: " << __DATE__ << " " << __TIME__ << std::endl;
|
||||
|
||||
DefaultSignalHandler::install();
|
||||
|
||||
QApplication app(argc, argv);
|
||||
try
|
||||
{
|
||||
|
@@ -11,54 +11,42 @@
|
||||
// psapi.h requires windows.h to be included
|
||||
#include <Windows.h>
|
||||
#include <Psapi.h>
|
||||
#include <tlhelp32.h>
|
||||
#endif
|
||||
|
||||
unsigned int getProcessIdsByProcessName(const char *processName, QStringList &listOfPids)
|
||||
QStringList getProcessIdsByProcessName(const char *processName)
|
||||
{
|
||||
// Clear content of returned list of PIDS
|
||||
listOfPids.clear();
|
||||
QStringList listOfPids;
|
||||
|
||||
#if defined(WIN32)
|
||||
// Get the list of process identifiers.
|
||||
DWORD aProcesses[1024], cbNeeded, cProcesses;
|
||||
unsigned int i;
|
||||
|
||||
if (!EnumProcesses(aProcesses, sizeof(aProcesses), &cbNeeded))
|
||||
return 0;
|
||||
|
||||
// Calculate how many process identifiers were returned.
|
||||
cProcesses = cbNeeded / sizeof(DWORD);
|
||||
|
||||
// Search for a matching name for each process
|
||||
for (i = 0; i < cProcesses; i++)
|
||||
// https://docs.microsoft.com/en-us/windows/win32/toolhelp/taking-a-snapshot-and-viewing-processes
|
||||
/* Take a snapshot of all processes in the system */
|
||||
HANDLE hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
|
||||
if(hProcessSnap == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
if (aProcesses[i] != 0)
|
||||
{
|
||||
char szProcessName[MAX_PATH] = {0};
|
||||
|
||||
DWORD processID = aProcesses[i];
|
||||
|
||||
// Get a handle to the process.
|
||||
HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, processID);
|
||||
|
||||
// Get the process name
|
||||
if (NULL != hProcess)
|
||||
{
|
||||
HMODULE hMod;
|
||||
DWORD cbNeeded;
|
||||
|
||||
if (EnumProcessModules(hProcess, &hMod, sizeof(hMod), &cbNeeded))
|
||||
GetModuleBaseNameA(hProcess, hMod, szProcessName, sizeof(szProcessName) / sizeof(char));
|
||||
|
||||
// Release the handle to the process.
|
||||
CloseHandle(hProcess);
|
||||
|
||||
if (*szProcessName != 0 && strcmp(processName, szProcessName) == 0)
|
||||
listOfPids.append(QString::number(processID));
|
||||
}
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
PROCESSENTRY32 pe32{};
|
||||
pe32.dwSize = sizeof(PROCESSENTRY32);
|
||||
|
||||
/* Retrieve information about the first process */
|
||||
if(!Process32First(hProcessSnap, &pe32))
|
||||
{
|
||||
CloseHandle(hProcessSnap);
|
||||
return {};
|
||||
}
|
||||
|
||||
/* Walk through the snapshot of processes */
|
||||
do
|
||||
{
|
||||
if (strcmp(processName, pe32.szExeFile) == 0)
|
||||
listOfPids.append(QString::number(pe32.th32ProcessID));
|
||||
|
||||
} while(Process32Next(hProcessSnap, &pe32));
|
||||
|
||||
CloseHandle(hProcessSnap);
|
||||
|
||||
#else
|
||||
|
||||
QDir dir("/proc");
|
||||
@@ -90,5 +78,5 @@ unsigned int getProcessIdsByProcessName(const char *processName, QStringList &li
|
||||
|
||||
#endif
|
||||
|
||||
return listOfPids.count();
|
||||
return listOfPids;
|
||||
}
|
||||
|
@@ -33,6 +33,7 @@
|
||||
#include <utils/FileUtils.h>
|
||||
#include <commandline/Parser.h>
|
||||
#include <commandline/IntOption.h>
|
||||
#include <utils/DefaultSignalHandler.h>
|
||||
#include <../../include/db/AuthTable.h>
|
||||
|
||||
#include "detectProcess.h"
|
||||
@@ -76,11 +77,6 @@ void signal_handler(const int signum)
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
QCoreApplication::quit();
|
||||
|
||||
// reset signal handler to default (in case this handler is not capable of stopping)
|
||||
signal(signum, SIG_DFL);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -150,14 +146,13 @@ int main(int argc, char** argv)
|
||||
|
||||
// check if we are running already an instance
|
||||
// TODO Allow one session per user
|
||||
// http://www.qtcentre.org/threads/44489-Get-Process-ID-for-a-running-application
|
||||
QStringList listOfPids;
|
||||
#ifdef _WIN32
|
||||
const char* processName = "hyperiond.exe";
|
||||
#else
|
||||
const char* processName = "hyperiond";
|
||||
#endif
|
||||
if (getProcessIdsByProcessName(processName, listOfPids) > 1)
|
||||
const QStringList listOfPids = getProcessIdsByProcessName(processName);
|
||||
if (listOfPids.size() > 1)
|
||||
{
|
||||
Error(log, "The Hyperion Daemon is already running, abort start");
|
||||
return 0;
|
||||
@@ -168,12 +163,10 @@ int main(int argc, char** argv)
|
||||
|
||||
bool isGuiApp = (qobject_cast<QApplication *>(app.data()) != 0 && QSystemTrayIcon::isSystemTrayAvailable());
|
||||
|
||||
DefaultSignalHandler::install();
|
||||
|
||||
#ifndef _WIN32
|
||||
signal(SIGINT, signal_handler);
|
||||
signal(SIGTERM, signal_handler);
|
||||
signal(SIGABRT, signal_handler);
|
||||
signal(SIGCHLD, signal_handler);
|
||||
signal(SIGPIPE, signal_handler);
|
||||
signal(SIGUSR1, signal_handler);
|
||||
signal(SIGUSR2, signal_handler);
|
||||
#endif
|
||||
@@ -309,7 +302,7 @@ int main(int argc, char** argv)
|
||||
// delete database before start
|
||||
if(parser.isSet(deleteDB))
|
||||
{
|
||||
QString dbFile = mDir.absolutePath() + "/db/hyperion.db";
|
||||
const QString dbFile = mDir.absolutePath() + "/db/hyperion.db";
|
||||
if (QFile::exists(dbFile))
|
||||
{
|
||||
if (!QFile::remove(dbFile))
|
||||
|
@@ -127,7 +127,7 @@ void SysTray::closeEvent(QCloseEvent *event)
|
||||
|
||||
void SysTray::settings()
|
||||
{
|
||||
#ifndef _WIN32
|
||||
#ifndef _WIN32
|
||||
// Hide error messages when opening webbrowser
|
||||
|
||||
int out_pipe[2];
|
||||
|
Reference in New Issue
Block a user