diff --git a/src/common.h b/src/common.h index 9c05326..6a8f058 100644 --- a/src/common.h +++ b/src/common.h @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -36,7 +37,7 @@ using namespace cv; using namespace std; using namespace std::filesystem; -#define APP_VER "1.6.t4" +#define APP_VER "1.6.t5" #define APP_NAME "Motion Watch" #define TRIM_REMOVE " \n\r\t\f\v." @@ -64,6 +65,7 @@ struct shared_t string webRoot; bool init; bool skipCmd; + bool updateRoot; int cmdFinished; int clipLen; int frameGap; diff --git a/src/main.cpp b/src/main.cpp index b22254b..6e39e18 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -141,8 +141,6 @@ void recLoop(shared_t *share) { while (rdConf(share)) { - recLog("rec_loop() -- start", share); - enforceMaxLogSize(share->recLogPath, share); enforceMaxLogSize(share->detLogPath, share); @@ -151,7 +149,9 @@ void recLoop(shared_t *share) initLogFrontPages(share); - if (!exists("/tmp/mow-lock")) + recLog("rec_loop() -- start", share); + + if (!exists("/tmp/mow-lock") && share->updateRoot) { system("touch /tmp/mow-lock"); @@ -160,10 +160,8 @@ void recLoop(shared_t *share) remove("/tmp/mow-lock"); recLog("webroot page updated: " + cleanDir(share->webRoot) + "/index.html", share); - } - else - { - recLog("skipping update of the webroot page, it is busy.", share); + + share->updateRoot = false; } genHTMLul(share->outDir, share->camName, share); @@ -238,10 +236,37 @@ void recLoop(shared_t *share) } } +void sigHandler(int signal, siginfo_t *info, void *context) +{ + cerr << "received signal details: " << endl; + cerr << "-- si_pid: " << info->si_pid << endl; + cerr << "-- si_signo: " << info->si_signo << endl; + cerr << "-- si_code: " << info->si_code << endl; + cerr << "-- si_errno: " << info->si_errno << endl; + cerr << "-- si_uid: " << info->si_uid << endl; + cerr << "-- si_addr: " << info->si_addr << endl; + cerr << "-- si_status: " << info->si_status << endl; + cerr << "-- si_band: " << info->si_band << endl; + + exit(EXIT_FAILURE); +} + int main(int argc, char** argv) { struct shared_t sharedRes; + struct sigaction act = { 0 }; + + act.sa_flags = SA_SIGINFO; + act.sa_sigaction = &sigHandler; + + sigaction(SIGTERM, &act, NULL); + sigaction(SIGABRT, &act, NULL); + sigaction(SIGSEGV, &act, NULL); + sigaction(SIGILL, &act, NULL); + sigaction(SIGFPE, &act, NULL); + sigaction(SIGBUS, &act, NULL); + sharedRes.conf = parseForList("-c", argc, argv); if (parseForParam("-h", argc, argv, true) == "true") @@ -266,9 +291,10 @@ int main(int argc, char** argv) } else { - sharedRes.retCode = 0; - sharedRes.skipCmd = false; - sharedRes.init = true; + sharedRes.retCode = 0; + sharedRes.updateRoot = true; + sharedRes.skipCmd = false; + sharedRes.init = true; recLoop(&sharedRes);