aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkremlin <ian@kremlin.cc>2014-08-05 10:30:41 +0800
committerkremlin <ian@kremlin.cc>2014-08-05 10:30:41 +0800
commit712eb32987872a6515e956246c0695fda032eb98 (patch)
treec422a5d645c3ad3a630967bdaa8d6a5735cd0885
parent341587dbd94b8845b91baef896d9da2693df19bb (diff)
downloadsystembsd-712eb32987872a6515e956246c0695fda032eb98.tar.gz
systembsd-712eb32987872a6515e956246c0695fda032eb98.tar.zst
systembsd-712eb32987872a6515e956246c0695fda032eb98.zip
(6) add handler for unix termination signals
it prints a message and calls foo_mem_clean(), swiftly and safely bringing the runtime down before letting the calling thread it was ready to exit. note, this is handled through GLib which guarantees it is only fired once, rather than unwrapped signals that can occur wildly.
-rw-r--r--src/interfaces/localed/localed.c9
-rw-r--r--src/interfaces/logind/logind.c9
-rw-r--r--src/interfaces/timedated/timedated.c9
3 files changed, 27 insertions, 0 deletions
diff --git a/src/interfaces/localed/localed.c b/src/interfaces/localed/localed.c
index e2fd3f4..83c8de2 100644
--- a/src/interfaces/localed/localed.c
+++ b/src/interfaces/localed/localed.c
@@ -133,6 +133,15 @@ void localed_mem_clean() {
}
+/* wrapper for glib's unix signal handling; called only once if terminating signal is raised against us */
+gboolean unix_sig_terminate_handler(gpointer data) {
+
+ g_printf("caught SIGINT/HUP/TERM, exiting\n");
+
+ localed_mem_clean();
+ return G_SOURCE_REMOVE;
+}
+
int main() {
localed_loop = g_main_loop_new(NULL, TRUE);
diff --git a/src/interfaces/logind/logind.c b/src/interfaces/logind/logind.c
index 78775cf..a0b0343 100644
--- a/src/interfaces/logind/logind.c
+++ b/src/interfaces/logind/logind.c
@@ -133,6 +133,15 @@ void logind_mem_clean() {
}
+/* wrapper for glib's unix signal handling; called only once if terminating signal is raised against us */
+gboolean unix_sig_terminate_handler(gpointer data) {
+
+ g_printf("caught SIGINT/HUP/TERM, exiting\n");
+
+ logind_mem_clean();
+ return G_SOURCE_REMOVE;
+}
+
int main() {
logind_loop = g_main_loop_new(NULL, TRUE);
diff --git a/src/interfaces/timedated/timedated.c b/src/interfaces/timedated/timedated.c
index 72d14f8..265a33f 100644
--- a/src/interfaces/timedated/timedated.c
+++ b/src/interfaces/timedated/timedated.c
@@ -133,6 +133,15 @@ void timedated_mem_clean() {
}
+/* wrapper for glib's unix signal handling; called only once if terminating signal is raised against us */
+gboolean unix_sig_terminate_handler(gpointer data) {
+
+ g_printf("caught SIGINT/HUP/TERM, exiting\n");
+
+ timedated_mem_clean();
+ return G_SOURCE_REMOVE;
+}
+
int main() {
timedated_loop = g_main_loop_new(NULL, TRUE);
d>-0/+2 * - Update to r347418.jkim2014-03-116-64/+33 * Convert j* to USES=zipbapt2014-03-1066-69/+67 * Remove expired ports:rene2014-03-104-50/+0 * - Include bsd.port.pre.mk before testing if ICONV_LIB is empty. It istijl2014-03-061-2/+8 * - Update to version 1.1.3pawel2014-03-062-18/+14 * - Update from 4.10 to 4.11danilo2014-03-052-24/+26 * - Sync. extremely outdated sun.util.resources.TimeZoneNames to the latestjkim2014-03-044-51/+4947 * - Reassign ports to the heaptabthorpe2014-03-0210-10/+10 * - Stage supportmiwi2014-02-261-10/+5 * Mark broken: Fails to buildantoine2014-02-221-0/+2 * Remove trailing whitespaces from category javaehaupt2014-02-212-2/+2 * Update subversion to 1.8.8.lev2014-02-211-3/+3 * - Support stagingehaupt2014-02-201-14/+10 * Stage supportantoine2014-02-191-3/+2 * - Stage supportantoine2014-02-181-8/+7 * - Stage supportantoine2014-02-181-16/+8 * - Stage supportantoine2014-02-181-8/+6 * Stage supportantoine2014-02-181-12/+4 * - Stage supportantoine2014-02-181-13/+5 * - Stage supportantoine2014-02-181-17/+7 * Fix build with DOCS-- requires build set up by src compilation.crees2014-02-171-4/+1 * Stage supportantoine2014-02-161-3/+2 * - Stage supportantoine2014-02-161-14/+5 * - Stage supportantoine2014-02-161-5/+2 * - Stage supportantoine2014-02-161-10/+3 * - Stage supportantoine2014-02-161-5/+2 * - Stage supportantoine2014-02-161-2/+1 * - Stage supportantoine2014-02-161-6/+3 * - Stage supportantoine2014-02-161-2/+1 * - Stage supportantoine2014-02-161-5/+2 * - Stage supportantoine2014-02-161-6/+3 * - Stage supportantoine2014-02-161-3/+2 * - Stage supportantoine2014-02-161-3/+2 * - Stage supportantoine2014-02-161-3/+2 * Stage supportantoine2014-02-161-7/+1 * Stage supportantoine2014-02-161-7/+1 * Stage supportantoine2014-02-161-12/+8 * - Stage supportantoine2014-02-161-15/+9 * - Stage supportantoine2014-02-161-8/+5 * - Stage supportantoine2014-02-161-5/+4 * Stage supportantoine2014-02-161-12/+6 * - Stage supportantoine2014-02-162-327/+310 * . Add BSD support to PortConfig. Fixes JMX on FreeBSD.glewis2014-02-162-0/+14 * - Reassign lioux' ports to the heaptabthorpe2014-02-152-2/+2 * - Really activate anti-aliasinggahr2014-02-131-1/+1 * - Update to 8.0-betagahr2014-02-134-2056/+1361 * Fix build with java7 and stagify.ale2014-02-111-13/+14 * According to the Porter's Handbook (5.12.2.3.) default options must be added toehaupt2014-02-103-0/+9 * . Remove OSVERSION checks. These are too restrictive but we don't haveglewis2014-02-101-4/+0 * Back to the futurbapt2014-02-101-1/+1 * Mark as deprecated unmaintained ports for which no public distfiles arebapt2014-02-101-0/+3 * . Update to 7u51.glewis2014-02-105-148530/+73812 * - Update to 1.3.7swills2014-02-084-341/+676 * Update to 1.4.2.jkim2014-02-072-4/+3 * Support stagebapt2014-02-062-26/+18 * - Stage supportmiwi2014-02-012-5/+2 * Upgrade to version 1.9.1, with staging support.olgeni2014-01-272-13/+9 * - Stage Safemiwi2014-01-241-1/+0 * Update to 1.6.1 release and stagify.ale2014-01-242-10/+9 * - Update to b30.jkim2014-01-24107-41306/+278 * Unbreak and stagify.ale2014-01-221-4/+1 * Support staging.ale2014-01-221-4/+4 * Fix properties on pkg-plistbapt2014-01-228-8/+0 * Update to 1.5.1 release and stagify.ale2014-01-223-26/+12 * . Update to 7u51.glewis2014-01-193-18/+3 * . Update to 7u51.glewis2014-01-193-20/+7 * java/eclipse-gef: BROKEN; fails to fetchmarino2014-01-161-0/+2 * - adopt staging supportjgh2014-01-111-4/+4 * - Reassign to the heap due to mail bouncestabthorpe2014-01-101-1/+1 * Build with Apache Ant 1.9.3.jkim2014-01-092-3/+3 * - Add LICENSEgahr2014-01-081-1/+4 * Revert lang/openjdk7 to 7u25.mat2014-01-045-43791/+148921 * Revert lang/openjdk6 to b28.mat2014-01-04107-264/+41295 * Part 2 at removing now useless FETCH_ARGS redifitionbapt2014-01-035-6/+0 * - rename AL2 to APACHE20 in Mk/bsd.licenses.db.mkohauer2013-12-316-6/+6 * Update to 1.9 release and stagify.ale2013-12-302-9/+9 * Update to 4.11 release and stagify.ale2013-12-302-19/+14 * Ouch. Remove >s from copy/pasting with vim tab hilightingcrees2013-12-301-7/+7 * Stage ports maintained by me in irc java mailcrees2013-12-293-70/+48 * Mark as forbidden, the port is now trigering a nasty FreeBSD bug!bapt2013-12-272-0/+4 * . Fix the POLICY option to actually install the unlimited strength policyglewis2013-12-271-4/+5 * Re-add jtreg to the distinfo.jkim2013-12-251-0/+2 * - Update to b29.jkim2013-12-25107-41296/+262 * Update freetype to 2.5.2.kwm2013-12-253-0/+46 * . Update to 2013iglewis2013-12-223-6/+3 * java/jmf java/dbvis: reset maintainereadler2013-12-112-2/+2 * If /var/db/zoneinfo exists, use the file to determine timezone rather thanjkim2013-12-113-12/+18 * - s/subversion-java/java-subversion/ohauer2013-12-091-1/+1 * - move java/subversion-java to java/java-subversion soohauer2013-12-093-2/+2 * . Update to 7u45.glewis2013-12-085-148920/+43788 * . Update to the latest cacerts from the 7u45 JDK release.glewis2013-12-081-0/+0 * Add multiple security patches and improvements from IcedTea6.jkim2013-12-05105-3/+41264 * - Return almost all of my ports back to the pool. I have no time to make anyaraujo2013-11-291-1/+1 * Most unkindly the java/java-getopt port changed the namemi2013-11-281-1/+1 * - Convert to dos2unix.mkmat2013-11-201-1/+1 * Replace LATEST_LINK with PKGNAMESUFFIX.olgeni2013-11-171-1/+2 * - Support staging.jkim2013-11-131-13/+10 * Change DESTDIRNAME into a ant compatible argument when a port is stagedbapt2013-11-121-3/+0 * Update to r333271.jkim2013-11-124-10/+16 * - Add throw() to all user-defined operator new()s within HotSpot becausejkim2013-11-093-20/+780 * . Update to 2013h.glewis2013-11-092-3/+3 * - Do not crash when unsupported options are specified. [1]jkim2013-11-063-63/+83 * Fix build with clang and stagify.ale2013-10-302-6/+17 * - Update to 7.4gahr2013-10-305-924/+662 * . Fix DefaultAsynchronousChannelProvider.create to not crash on FreeBSD butglewis2013-10-302-1/+14 * Update to 1.0.14 release and much more.ale2013-10-293-16/+25 * Update to libmpc version 1.0.1 which brings the following fixes:gerald2013-10-261-0/+1 * - Turn off UseMembar by default. This workaround is not necessary any more.jkim2013-10-263-9/+109 * . Update to 7u45.glewis2013-10-242-3/+3 * . Update to 7u45.glewis2013-10-243-3/+4 * . Update to 7u45.glewis2013-10-243-5/+9 * Allow overriding linker flags for standard C++ libraries and zlib.jkim2013-10-232-9/+18 * - Remove manual creation and removal of share/applications, as it's now in th...amdmi32013-10-221-1/+0 * - Update to r330538.jkim2013-10-225-10/+55 * - Avoid PKGNAME collision.eadler2013-10-221-1/+2 * Fix pkgname collisionbapt2013-10-182-4/+4 * Allow adding extra patches from slave ports.jkim2013-10-171-1/+1 * Clean up some COMMENTseadler2013-10-161-1/+1 * Chase misc/compat8x change. libstdc++.so.6 is now available from compat9x.jkim2013-10-161-0/+3 * Fix build on old releases where nitems() macro is not defined.jkim2013-10-161-2/+2 * Build with Apache Ant 1.9.2.jkim2013-10-152-3/+3 * Simplify compiler detection. COMPILER_TYPE must be defined since r330336.jkim2013-10-151-1/+1 * Fix package name collisionbapt2013-10-141-2/+1 * Update to r330107 (OpenJDK6 b28).jkim2013-10-133-6/+6 * . Update to 2013g.glewis2013-10-132-3/+3 * - Do not allow selecting both DEBUG and FASTDEBUG options. [1]jkim2013-10-123-35/+18 * - Fix few mis-merges against HotSpot 23 and tie up some loose ends.jkim2013-10-116-71/+133 * Update to 1.4.1.jkim2013-10-115-58/+3 * - Remove redundant bsd.port.pre.mk.jkim2013-10-111-4/+2 * Add couple of compiler warning fixes. No functional change.jkim2013-10-101-1/+12 * Update to Build b28.jkim2013-10-10167-168839/+277 * Fix test option.jkim2013-10-081-2/+3 * Use echo correctly.jkim2013-10-081-14/+14 * Remove few lines added for testing at the last minute. This fixes plist.jkim2013-10-081-3/+0 * - Support staging.jkim2013-10-084-107/+191 * Fix pkg name collisionbapt2013-10-072-2/+2 * Fix pkg name collisionbapt2013-10-072-2/+2 * - Support staginglme2013-10-062-75/+78 * Removed older version of netbeans, they are unsupported upstream and their pa...bapt2013-10-0316-265/+0 * Remove jboss2, it is EOLed upstream and it's name is conflicting with java/jb...bapt2013-10-039-2112/+0 * . Update to 2013f.glewis2013-09-283-18/+3 * Update to 4.10 release.ale2013-09-272-3/+3 * Tidy up staging support.jkim2013-09-261-5/+1 * Add support for staging.jkim2013-09-261-2/+1 * . Make set_native_priority return a (correct) value on FreeBSD, rather thanglewis2013-09-222-0/+9 * Add NO_STAGE all over the place in preparation for the staging support (cat: ...bapt2013-09-21143-161/+178 * . Update to 7u40.glewis2013-09-192-3/+3 * . Update to 7u40.glewis2013-09-193-9/+9 * . Update to 7u40.glewis2013-09-193-12/+420 * - Add missing iconv USESmadpilot2013-09-161-1/+1 * - convert to the new perl5 frameworkaz2013-09-15