]> andersk Git - moira.git/blobdiff - clients/moira/namespace.c
Diane Delgado's changes for a fixed table-locking order
[moira.git] / clients / moira / namespace.c
index c244af6dfbfdf9d8c8a103e89df78fa0a1f6fc6b..fa6c00f9e555e2e971e637daf88aaa16a7234376 100644 (file)
@@ -22,7 +22,7 @@
 #include <pwd.h>
 #include <signal.h>
 #include <stdio.h>
-#include <strings.h>
+#include <string.h>
 #include <sys/types.h>
 #include <moira.h>
 #include <menu.h>
@@ -36,6 +36,7 @@
 
 char * whoami;                 /* used by menu.c ugh!!! */
 char * moira_server;
+int interrupt = 0;
 int NewListHelp();
 
 /*
@@ -46,7 +47,7 @@ Menu list_info_menu = {
     NULLFUNC,
     NULLFUNC,
     "List Information Menu",
-    4,
+    3,
     {
         SIMPLEFUNC("member", "Show all lists to which a given member belongs",
                   ListByMember),
@@ -55,8 +56,6 @@ Menu list_info_menu = {
                   ListByAdministrator),
        SIMPLEFUNC("public", "Show all public mailing lists",
                   ListAllPublicMailLists),
-       SIMPLEFUNC("maillists", "Show all mailing lists",
-                  ListAllMailLists)
     }
 };
 
@@ -167,7 +166,7 @@ Menu namespace_menu = {
 
 
 #ifndef DEBUG
-static void SignalHandler();
+static void SignalHandler(), CatchInterrupt();
 #endif DEBUG
 
 static void ErrorExit(), Usage();
@@ -192,8 +191,11 @@ main(argc, argv)
     Menu *menu;
     char *motd, **arg;
     char pname[ANAME_SZ];
+#ifdef POSIX
+    struct sigaction act;
+#endif
 
-    if ((program_name = rindex(argv[0], '/')) == NULL)
+    if ((program_name = strrchr(argv[0], '/')) == NULL)
       program_name = argv[0];
     else
       program_name++;
@@ -256,10 +258,27 @@ main(argc, argv)
  */
 
 #ifndef DEBUG
+#ifdef POSIX
+    sigemptyset(&act.sa_mask);
+    act.sa_flags = 0;
+    act.sa_handler= (void (*)()) SignalHandler;
+    (void) sigaction(SIGHUP, &act, NULL);
+    (void) sigaction(SIGQUIT, &act, NULL);
+    if (use_menu)
+      (void) sigaction(SIGINT, &act, NULL); 
+    else {
+       act.sa_handler= (void (*)()) CatchInterrupt;
+       (void) sigaction(SIGINT, &act, NULL); 
+    }
+#else
     (void) signal(SIGHUP, SignalHandler);
-    (void) signal(SIGINT, SignalHandler); 
     (void) signal(SIGQUIT, SignalHandler);
-#endif DEBUG
+    if (use_menu)
+      (void) signal(SIGINT, SignalHandler); 
+    else
+      (void) signal(SIGINT, CatchInterrupt); 
+#endif /* POSIX */
+#endif /* DEBUG */
 
     menu = &namespace_menu;
 
@@ -321,6 +340,14 @@ SignalHandler()
     mr_disconnect();
     exit(1);
 }
+
+
+static void
+CatchInterrupt()
+{
+    Put_message("Interrupt! Press RETURN to continue");
+    interrupt = 1;
+}
 #endif DEBUG
 
 
This page took 0.035441 seconds and 4 git commands to generate.