bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

console-client signal handling


From: Marco Gerards
Subject: console-client signal handling
Date: Wed, 14 Jul 2004 22:44:33 +0200
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux)

Hi,

Many people complain on IRC about the console client and that it does
not catch the signals.  So when you send a SIGTERM signal to the
console it does not correctly clean up its state.  The same is true
for the SIGINT signal.

This patch fixes the problem.  Marcus, can I commit this patch?

Thanks,
Marco


2004-07-14  Marco Gerards  <metgerards@student.han.nl>

        * console.c (sighandler): New function.
        (HANDLE_SIGNAL): New macro.
        (main): Handle the signals SIGINT and SIGTERM.


Index: console.c
===================================================================
RCS file: /cvsroot/hurd/hurd/console-client/console.c,v
retrieving revision 1.4
diff -u -p -r1.4 console.c
--- console.c   21 Mar 2004 19:57:00 -0000      1.4
+++ console.c   14 Jul 2004 20:42:58 -0000
@@ -446,6 +446,19 @@ static const struct argp_child startup_c
 static struct argp startup_argp = {options, parse_opt, 0,
                                   0, startup_children};
 
+static void
+sighandler (int sig)
+{
+  console_exit ();
+}
+
+#define HANDLE_SIGNAL(SIG)                             \
+  if (signal (SIG, sighandler))                                \
+    {                                                  \
+      driver_fini ();                                  \
+      error (1, errno, "Couldn't set signal handler"); \
+    }
+
 int
 main (int argc, char *argv[])
 {
@@ -456,7 +469,10 @@ main (int argc, char *argv[])
 
   /* Parse our command line.  This shouldn't ever return an error.  */
   argp_parse (&startup_argp, argc, argv, ARGP_IN_ORDER, 0, 0);
-
+  
+  HANDLE_SIGNAL (SIGTERM);
+  HANDLE_SIGNAL (SIGINT);
+  
   err = driver_start (&errname);
   if (err)
     error (1, err, "Starting driver %s failed", errname);





reply via email to

[Prev in Thread] Current Thread [Next in Thread]