butc: clean xbsa shutdown on control C
authorRainer Toebbicke <rtb@pclella.cern.ch>
Wed, 19 Sep 2012 16:13:15 +0000 (12:13 -0400)
committerDerrick Brashear <shadow@your-file-system.com>
Wed, 19 Sep 2012 18:57:45 +0000 (11:57 -0700)
when we catch a control-c, do a clean shutdown

Change-Id: I8da28c28d0a238d3642f65c381c399a883d6d4b1
Reviewed-on: http://gerrit.openafs.org/8141
Reviewed-by: Chas Williams - CONTRACTOR <chas@cmf.nrl.navy.mil>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>

src/butc/tcmain.c

index 98e6f71..3bf6f2d 100644 (file)
@@ -822,6 +822,15 @@ GetConfigParams(char *filename, afs_int32 port)
     return (code);
 }
 
+#ifdef xbsa
+static void
+xbsa_shutdown(int x)
+{
+    xbsa_Finalize(&butxInfo);
+    exit(0);
+}
+#endif
+
 static int
 WorkerBee(struct cmd_syndesc *as, void *arock)
 {
@@ -1008,6 +1017,8 @@ WorkerBee(struct cmd_syndesc *as, void *arock)
        rc = InitToServer(0 /*taskid */ , &butxInfo, adsmServerName);
        if (rc != XBSA_SUCCESS)
            return (1);
+       (void)signal(SIGINT, xbsa_shutdown);
+       (void)signal(SIGHUP, xbsa_shutdown);
     }
 #endif /*xbsa */