| 1 | // SPDX-License-Identifier: GPL-3.0-or-latercxx . . $ `<file>/src/main.cpp`/ |
| 2 | // Copyright 2019 Juan Palacios <[email protected]> |
| 3 | |
| 4 | #include "app/app.h"cxx . . $ `<file>/src/app/app.h`/ |
| 5 | #include "common/logger.h"cxx . . $ `<file>/src/common/logger.h`/ |
| 6 | #include <QCoreApplication> |
| 7 | #include <signal.h> |
| 8 | |
| 9 | // Handle easily unix signals |
| 10 | // |
| 11 | // Credits: Amir Zamani |
| 12 | // https://gist.github.com/azadkuh/a2ac6869661ebd3f8588#file-qt-unix-signals-md |
| 13 | void catchUnixSignalscxx . . $ catchUnixSignals(b66fca70a6fa7a65).(stdcxx . . $ std/::initializer_listcxx . . $ std/initializer_list#<int> quitSignals) |
| 14 | { |
| 15 | auto handler = [](int) -> void { |
| 16 | QMetaObjectcxx . . $ QMetaObject#::invokeMethodcxx . . $ QMetaObject#invokeMethod(8b0e30ae6de741c4).(QCoreApplicationcxx . . $ QCoreApplication#::instancecxx . . $ QCoreApplication#instance(fc464b6fd63b8c1).(), "quit", |
| 17 | Qtcxx . . $ Qt/::QueuedConnectioncxx . . $ Qt/QueuedConnection.); |
| 18 | }; |
| 19 | |
| 20 | sigset_t blocking_mask; |
| 21 | sigemptyset(&blocking_mask); |
| 22 | for (auto sig : quitSignals) |
| 23 | sigaddset(&blocking_mask, sig); |
| 24 | |
| 25 | struct sigaction sa; |
| 26 | sa.sa_handlercxx . . $ `<external>/16635209305659446502/sigaction.h:39:10`! = handler; |
| 27 | sa.sa_mask =cxx . . $ $anonymous_type_ea04d1c8b46dfcbb_0#`operator=`(503aacc6828bcf39). blocking_mask; |
| 28 | sa.sa_flags = 0; |
| 29 | |
| 30 | for (auto sig : quitSignals) |
| 31 | sigaction(sig, &sa, nullptr); |
| 32 | } |
| 33 | |
| 34 | int maincxx . . $ main(afcd3168fc1188a4).(int argc, char **argv) |
| 35 | { |
| 36 | setupLoggercxx . . $ setupLogger(3f42e2c2fac0d5fc).(stdcxx . . $ std/::filesystemcxx . . $ std/filesystem/::temp_directory_pathcxx . . $ std/filesystem/temp_directory_path(4c12bfa3c403d782).() /cxx . . $ std/filesystem/__cxx11/`operator/`(578e0438ad5f0e7e). |
| 37 | (cxx . . $ std/filesystem/__cxx11/path#path(2f6c7066048c5333).stdcxx . . $ std/::stringcxx . . $ std/string#(Appcxx . . $ App#::Namecxx . . $ App#Name.) +cxx . . $ std/operator+(900ec9581c410ad9). ".log")); |
| 38 | |
| 39 | SPDLOG_DEBUGcxx . . $ `<external>/13613935168682455490/spdlog.h:311:13`!("----- Application started -----"); |
| 40 | |
| 41 | catchUnixSignalscxx . . $ catchUnixSignals(b66fca70a6fa7a65).({SIGQUITcxx . . $ `<external>/11773118241360591791/signum-generic.h:57:9`!, SIGINTcxx . . $ `<external>/11773118241360591791/signum-generic.h:48:9`!, SIGTERMcxx . . $ `<external>/11773118241360591791/signum-generic.h:53:9`!, SIGHUPcxx . . $ `<external>/11773118241360591791/signum-generic.h:56:9`!}); |
| 42 | |
| 43 | return Appcxx . . $ App#App(ced63f7c635d850d).().execcxx . . $ App#exec(afcd3168fc1188a4).(argc, argv); |
| 44 | } |