[smuxi] Frontend-GNOME: install signal handlers for SIGINT/TERM
- From: Mirco M. M. Bauer <mmmbauer src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [smuxi] Frontend-GNOME: install signal handlers for SIGINT/TERM
- Date: Thu, 23 Apr 2015 05:12:37 +0000 (UTC)
commit ac085d58e0c3495a371fbba0c912df9be6ca17b8
Author: Mirco Bauer <meebey meebey net>
Date: Thu Apr 23 07:08:19 2015 +0200
Frontend-GNOME: install signal handlers for SIGINT/TERM
^C from the terminal (SIGINT) does no longer work for the first Smuxi instance
as the SingleApplicationInstance library installs Unix signal handlers for
SIGINT to cleanup lock files. GTK+ does no longer handle SIGINT itself when
there are already installed signal handlers. Thus the GNOME frontend has to
explicitly install signal handlers itself.
src/Frontend-GNOME/Frontend.cs | 30 +++++++++++++++++++++++++++++-
1 files changed, 29 insertions(+), 1 deletions(-)
---
diff --git a/src/Frontend-GNOME/Frontend.cs b/src/Frontend-GNOME/Frontend.cs
index c23a07f..14ba9bb 100644
--- a/src/Frontend-GNOME/Frontend.cs
+++ b/src/Frontend-GNOME/Frontend.cs
@@ -1,7 +1,7 @@
/*
* Smuxi - Smart MUltipleXed Irc
*
- * Copyright (c) 2005-2014 Mirco Bauer <meebey meebey net>
+ * Copyright (c) 2005-2015 Mirco Bauer <meebey meebey net>
*
* Full GPL License: <http://www.gnu.org/licenses/gpl.txt>
*
@@ -27,6 +27,8 @@ using System.Linq;
using System.Threading;
using System.Reflection;
using SysDiag = System.Diagnostics;
+using Mono.Unix;
+using Mono.Unix.Native;
using MonoDevelop.MacInterop;
using Smuxi.Engine;
using Smuxi.Common;
@@ -203,6 +205,7 @@ namespace Smuxi.Frontend.Gnome
_Logger.Info(_VersionString + " starting");
#endif
+ InitSignalHandlers();
InitGtk(args);
//_SplashScreenWindow = new SplashScreenWindow();
@@ -1024,6 +1027,31 @@ namespace Smuxi.Frontend.Gnome
return false;
}
+ static void InitSignalHandlers()
+ {
+ if ((Environment.OSVersion.Platform == PlatformID.Unix) ||
+ (Environment.OSVersion.Platform == PlatformID.MacOSX)) {
+ // Register shutdown handlers
+#if LOG4NET
+ _Logger.Info("Registering signal handlers");
+#endif
+ UnixSignal[] shutdown_signals = {
+ new UnixSignal(Signum.SIGINT),
+ new UnixSignal(Signum.SIGTERM),
+ };
+ Thread signal_thread = new Thread(() => {
+ var index = UnixSignal.WaitAny(shutdown_signals);
+#if LOG4NET
+ _Logger.Info("Caught signal " + shutdown_signals[index].Signum.ToString() + ", shutting
down");
+#endif
+ Gtk.Application.Invoke(delegate {
+ Quit();
+ });
+ });
+ signal_thread.Start();
+ }
+ }
+
private static void InitGtk(string[] args)
{
if (Environment.OSVersion.Platform == PlatformID.Win32NT) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]