Index: /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/Makefile
===================================================================
--- /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/Makefile	(revision 38616)
+++ /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/Makefile	(revision 38617)
@@ -78,4 +78,6 @@
 $(SRC)/update_catalog_setphot.$(ARCH).o \
 $(SRC)/initialize_setphot_client.$(ARCH).o \
+$(SRC)/SetSignals.$(ARCH).o	    \
+$(SRC)/Shutdown.$(ARCH).o	    \
 $(SRC)/ImageSubset.$(ARCH).o
 
@@ -136,4 +138,6 @@
 $(SRC)/repair_tycho_setastrom.$(ARCH).o \
 $(SRC)/astrom_correction.$(ARCH).o \
+$(SRC)/SetSignals.$(ARCH).o	    \
+$(SRC)/Shutdown.$(ARCH).o	    \
 $(SRC)/initialize_setastrom.$(ARCH).o
 
@@ -158,4 +162,6 @@
 $(SRC)/update_catalog_setgalmodel.$(ARCH).o \
 $(SRC)/galmodel_correction.$(ARCH).o \
+$(SRC)/SetSignals.$(ARCH).o	    \
+$(SRC)/Shutdown.$(ARCH).o	    \
 $(SRC)/initialize_setgalmodel.$(ARCH).o
 
@@ -234,4 +240,6 @@
 $(SRC)/initialize_ckids.$(ARCH).o     \
 $(SRC)/update_dvo_ckids.$(ARCH).o     \
+$(SRC)/SetSignals.$(ARCH).o	    \
+$(SRC)/Shutdown.$(ARCH).o	    \
 $(SRC)/update_catalog_ckids.$(ARCH).o
 
@@ -243,4 +251,6 @@
 $(SRC)/initialize_ckids.$(ARCH).o     \
 $(SRC)/update_dvo_ckids.$(ARCH).o     \
+$(SRC)/SetSignals.$(ARCH).o	    \
+$(SRC)/Shutdown.$(ARCH).o	    \
 $(SRC)/update_catalog_ckids.$(ARCH).o
 
Index: /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/include/ckids.h
===================================================================
--- /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/include/ckids.h	(revision 38616)
+++ /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/include/ckids.h	(revision 38617)
@@ -34,2 +34,8 @@
 					            
 void          update_catalog_ckids              PROTO((Catalog *catalog, FILE *foutput));
+
+int           Shutdown                        PROTO((char *format, ...) OHANA_FORMAT(printf, 1, 2) );
+void          TrapSignal                      PROTO((int sig));
+void          SetProtect                      PROTO((int mode));
+int           SetSignals                      PROTO((void));
+
Index: /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/include/setastrom.h
===================================================================
--- /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/include/setastrom.h	(revision 38616)
+++ /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/include/setastrom.h	(revision 38617)
@@ -72,8 +72,8 @@
 int           args_setastrom_client           PROTO((int argc, char **argv));
 
-// int           Shutdown                        PROTO((char *format, ...) OHANA_FORMAT(printf, 1, 2) );
-// void          TrapSignal                      PROTO((int sig));
-// void          SetProtect                      PROTO((int mode));
-// int           SetSignals                      PROTO((void));
+int           Shutdown                        PROTO((char *format, ...) OHANA_FORMAT(printf, 1, 2) );
+void          TrapSignal                      PROTO((int sig));
+void          SetProtect                      PROTO((int mode));
+int           SetSignals                      PROTO((void));
 
 int           update_dvo_setastrom            PROTO((void));
Index: /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/include/setgalmodel.h
===================================================================
--- /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/include/setgalmodel.h	(revision 38616)
+++ /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/include/setgalmodel.h	(revision 38617)
@@ -34,8 +34,8 @@
 int           args_setgalmodel_client           PROTO((int argc, char **argv));
 
-// int           Shutdown                        PROTO((char *format, ...) OHANA_FORMAT(printf, 1, 2) );
-// void          TrapSignal                      PROTO((int sig));
-// void          SetProtect                      PROTO((int mode));
-// int           SetSignals                      PROTO((void));
+int           Shutdown                        PROTO((char *format, ...) OHANA_FORMAT(printf, 1, 2) );
+void          TrapSignal                      PROTO((int sig));
+void          SetProtect                      PROTO((int mode));
+int           SetSignals                      PROTO((void));
 
 int           update_dvo_setgalmodel            PROTO((void));
Index: /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/Shutdown.c
===================================================================
--- /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/Shutdown.c	(revision 38616)
+++ /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/Shutdown.c	(revision 38617)
@@ -21,6 +21,4 @@
   va_end (argp);
 
-  SetProtect (TRUE);
-  gfits_db_close (db);
   fprintf (stderr, "ERROR: halted\n");
   exit (1);
Index: /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/ckids.c
===================================================================
--- /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/ckids.c	(revision 38616)
+++ /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/ckids.c	(revision 38617)
@@ -6,4 +6,5 @@
 
   /* get configuration info, args, lockfile */
+  SetSignals ();
   initialize_ckids (argc, argv);
 
Index: /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/ckids_client.c
===================================================================
--- /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/ckids_client.c	(revision 38616)
+++ /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/ckids_client.c	(revision 38617)
@@ -12,4 +12,5 @@
 
   // get configuration info, args, lockfile (set CATDIR, HOST_ID, HOSTDIR, IMAGES)
+  SetSignals ();
   initialize_ckids_client (argc, argv);
 
Index: /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/fiximids.c
===================================================================
--- /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/fiximids.c	(revision 38616)
+++ /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/fiximids.c	(revision 38617)
@@ -8,4 +8,5 @@
 
   /* get configuration info, args, lockfile */
+  SetSignals ();
   initialize_fiximids (argc, argv);
 
Index: /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/fiximids_client.c
===================================================================
--- /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/fiximids_client.c	(revision 38616)
+++ /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/fiximids_client.c	(revision 38617)
@@ -13,4 +13,5 @@
 
   // get configuration info, args, lockfile (set CATDIR, HOST_ID, HOSTDIR, IMAGES)
+  SetSignals ();
   initialize_fiximids_client (argc, argv);
 
Index: /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/fixstkids.c
===================================================================
--- /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/fixstkids.c	(revision 38616)
+++ /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/fixstkids.c	(revision 38617)
@@ -8,4 +8,5 @@
 
   /* get configuration info, args, lockfile */
+  SetSignals ();
   initialize_fixstkids (argc, argv);
 
Index: /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/fixstkids_client.c
===================================================================
--- /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/fixstkids_client.c	(revision 38616)
+++ /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/fixstkids_client.c	(revision 38617)
@@ -13,4 +13,5 @@
 
   // get configuration info, args, lockfile (set CATDIR, HOST_ID, HOSTDIR, IMAGES)
+  SetSignals ();
   initialize_fixstkids_client (argc, argv);
 
Index: /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/setastrom.c
===================================================================
--- /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/setastrom.c	(revision 38616)
+++ /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/setastrom.c	(revision 38617)
@@ -6,4 +6,5 @@
 
   /* get configuration info, args, lockfile */
+  SetSignals ();
   initialize_setastrom (argc, argv);
 
Index: /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/setastrom_client.c
===================================================================
--- /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/setastrom_client.c	(revision 38616)
+++ /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/setastrom_client.c	(revision 38617)
@@ -13,4 +13,5 @@
 
   // get configuration info, args, lockfile (set CATDIR, HOST_ID, HOSTDIR, IMAGES)
+  SetSignals ();
   initialize_setastrom_client (argc, argv);
 
Index: /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/setfwhm.c
===================================================================
--- /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/setfwhm.c	(revision 38616)
+++ /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/setfwhm.c	(revision 38617)
@@ -10,4 +10,5 @@
 
   /* get configuration info, args, lockfile */
+  SetSignals ();
   initialize_setfwhm (argc, argv);
 
Index: /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/setgalmodel.c
===================================================================
--- /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/setgalmodel.c	(revision 38616)
+++ /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/setgalmodel.c	(revision 38617)
@@ -6,4 +6,5 @@
 
   /* get configuration info, args, lockfile */
+  SetSignals ();
   initialize_setgalmodel (argc, argv);
 
Index: /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/setgalmodel_client.c
===================================================================
--- /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/setgalmodel_client.c	(revision 38616)
+++ /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/setgalmodel_client.c	(revision 38617)
@@ -13,4 +13,5 @@
 
   // get configuration info, args, lockfile (set CATDIR, HOST_ID, HOSTDIR, IMAGES)
+  SetSignals ();
   initialize_setgalmodel_client (argc, argv);
 
Index: /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/setphot.c
===================================================================
--- /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/setphot.c	(revision 38616)
+++ /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/setphot.c	(revision 38617)
@@ -11,4 +11,5 @@
 
   /* get configuration info, args, lockfile */
+  SetSignals ();
   initialize_setphot (argc, argv);
 
@@ -50,5 +51,7 @@
   // write image table (even if some remote clients failed)
   if (UPDATE) {
+    SetProtect (TRUE);
     dvo_image_save (&db, VERBOSE);
+    SetProtect (FALSE);
   }
 
Index: /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/setphot_client.c
===================================================================
--- /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/setphot_client.c	(revision 38616)
+++ /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/setphot_client.c	(revision 38617)
@@ -13,4 +13,5 @@
 
   // get configuration info, args, lockfile (set CATDIR, HOST_ID, HOSTDIR, IMAGES)
+  SetSignals ();
   initialize_setphot_client (argc, argv);
 
Index: /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/setposangle.c
===================================================================
--- /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/setposangle.c	(revision 38616)
+++ /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/setposangle.c	(revision 38617)
@@ -8,4 +8,5 @@
 
   /* get configuration info, args, lockfile */
+  SetSignals ();
   initialize_setposangle (argc, argv);
 
Index: /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/setposangle_client.c
===================================================================
--- /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/setposangle_client.c	(revision 38616)
+++ /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/setposangle_client.c	(revision 38617)
@@ -13,4 +13,5 @@
 
   // get configuration info, args, lockfile (set CATDIR, HOST_ID, HOSTDIR, IMAGES)
+  SetSignals ();
   initialize_setposangle_client (argc, argv);
 
Index: /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/uniphot.c
===================================================================
--- /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/uniphot.c	(revision 38616)
+++ /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/uniphot.c	(revision 38617)
@@ -16,4 +16,5 @@
 
   /* get configuration info, args, lockfile */
+  SetSignals ();
   initialize_uniphot (argc, argv);
 
Index: /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/update_dvo_ckids.c
===================================================================
--- /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/update_dvo_ckids.c	(revision 38616)
+++ /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/update_dvo_ckids.c	(revision 38617)
@@ -69,6 +69,8 @@
     if (VERBOSE) fprintf (stderr, "saving catalog %s\n", catalog.filename);
     
-    dvo_catalog_save (&catalog, VERBOSE); 
-    dvo_catalog_unlock (&catalog);
+    SetProtect (TRUE);
+    if (!dvo_catalog_save (&catalog, VERBOSE)) { fprintf (stderr, "ERROR: failed to save %s\n", catalog.filename); exit (1); }
+    if (!dvo_catalog_unlock (&catalog)) { fprintf (stderr, "ERROR: failed to unlock %s\n", catalog.filename); exit (1); }
+    SetProtect (FALSE);
     dvo_catalog_free (&catalog);
   }
Index: /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/update_dvo_fiximids.c
===================================================================
--- /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/update_dvo_fiximids.c	(revision 38616)
+++ /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/update_dvo_fiximids.c	(revision 38617)
@@ -64,6 +64,8 @@
     if (VERBOSE) fprintf (stderr, "saving catalog %s\n", catalog.filename);
     
-    dvo_catalog_save (&catalog, VERBOSE); 
-    dvo_catalog_unlock (&catalog);
+    SetProtect (TRUE);
+    if (!dvo_catalog_save (&catalog, VERBOSE)) { fprintf (stderr, "ERROR: failed to save %s\n", catalog.filename); exit (1); }
+    if (!dvo_catalog_unlock (&catalog)) { fprintf (stderr, "ERROR: failed to unlock %s\n", catalog.filename); exit (1); }
+    SetProtect (FALSE);
     dvo_catalog_free (&catalog);
   }
Index: /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/update_dvo_fixstkids.c
===================================================================
--- /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/update_dvo_fixstkids.c	(revision 38616)
+++ /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/update_dvo_fixstkids.c	(revision 38617)
@@ -64,6 +64,8 @@
     if (VERBOSE) fprintf (stderr, "saving catalog %s\n", catalog.filename);
     
-    dvo_catalog_save (&catalog, VERBOSE); 
-    dvo_catalog_unlock (&catalog);
+    SetProtect (TRUE);
+    if (!dvo_catalog_save (&catalog, VERBOSE)) { fprintf (stderr, "ERROR: failed to save %s\n", catalog.filename); exit (1); }
+    if (!dvo_catalog_unlock (&catalog)) { fprintf (stderr, "ERROR: failed to unlock %s\n", catalog.filename); exit (1); }
+    SetProtect (FALSE);
     dvo_catalog_free (&catalog);
   }
Index: /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/update_dvo_setastrom.c
===================================================================
--- /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/update_dvo_setastrom.c	(revision 38616)
+++ /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/update_dvo_setastrom.c	(revision 38617)
@@ -74,6 +74,8 @@
     if (VERBOSE) fprintf (stderr, "saving catalog %s\n", catalog.filename);
     
-    dvo_catalog_save (&catalog, VERBOSE); 
-    dvo_catalog_unlock (&catalog);
+    SetProtect (TRUE);
+    if (!dvo_catalog_save (&catalog, VERBOSE)) { fprintf (stderr, "ERROR: failed to save %s\n", catalog.filename); exit (1); }
+    if (!dvo_catalog_unlock (&catalog)) { fprintf (stderr, "ERROR: failed to unlock %s\n", catalog.filename); exit (1); }
+    SetProtect (FALSE);
     dvo_catalog_free (&catalog);
   }
Index: /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/update_dvo_setgalmodel.c
===================================================================
--- /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/update_dvo_setgalmodel.c	(revision 38616)
+++ /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/update_dvo_setgalmodel.c	(revision 38617)
@@ -66,6 +66,8 @@
     if (VERBOSE) fprintf (stderr, "saving catalog %s\n", catalog.filename);
     
-    dvo_catalog_save (&catalog, VERBOSE); 
-    dvo_catalog_unlock (&catalog);
+    SetProtect (TRUE);
+    if (!dvo_catalog_save (&catalog, VERBOSE)) { fprintf (stderr, "ERROR: failed to save %s\n", catalog.filename); exit (1); }
+    if (!dvo_catalog_unlock (&catalog)) { fprintf (stderr, "ERROR: failed to unlock %s\n", catalog.filename); exit (1); }
+    SetProtect (FALSE);
     dvo_catalog_free (&catalog);
   }
Index: /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/update_dvo_setphot.c
===================================================================
--- /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/update_dvo_setphot.c	(revision 38616)
+++ /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/update_dvo_setphot.c	(revision 38617)
@@ -77,6 +77,8 @@
     if (VERBOSE) fprintf (stderr, "saving catalog %s\n", catalog.filename);
     
-    dvo_catalog_save (&catalog, VERBOSE); 
-    dvo_catalog_unlock (&catalog);
+    SetProtect (TRUE);
+    if (!dvo_catalog_save (&catalog, VERBOSE)) { fprintf (stderr, "ERROR: failed to save %s\n", catalog.filename); exit (1); }
+    if (!dvo_catalog_unlock (&catalog)) { fprintf (stderr, "ERROR: failed to unlock %s\n", catalog.filename); exit (1); }
+    SetProtect (FALSE);
     dvo_catalog_free (&catalog);
   }
Index: /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/update_dvo_setposangle.c
===================================================================
--- /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/update_dvo_setposangle.c	(revision 38616)
+++ /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/update_dvo_setposangle.c	(revision 38617)
@@ -78,6 +78,8 @@
     if (VERBOSE) fprintf (stderr, "saving catalog %s\n", catalog.filename);
     
-    dvo_catalog_save (&catalog, VERBOSE); 
-    dvo_catalog_unlock (&catalog);
+    SetProtect (TRUE);
+    if (!dvo_catalog_save (&catalog, VERBOSE)) { fprintf (stderr, "ERROR: failed to save %s\n", catalog.filename); exit (1); }
+    if (!dvo_catalog_unlock (&catalog)) { fprintf (stderr, "ERROR: failed to unlock %s\n", catalog.filename); exit (1); }
+    SetProtect (FALSE);
     dvo_catalog_free (&catalog);
   }
Index: /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/update_dvo_uniphot.c
===================================================================
--- /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/update_dvo_uniphot.c	(revision 38616)
+++ /branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/update_dvo_uniphot.c	(revision 38617)
@@ -101,6 +101,8 @@
     fprintf (stderr, "catalog: %s sgroup: %d %s %f\n", catalog.filename, Nmin, sgroup[Nmin].label, Rmin);
     update_catalog_uniphot (&catalog, &sgroup[Nmin], (Rmin > 2*RADIUS)); 
-    dvo_catalog_save (&catalog, VERBOSE);
-    dvo_catalog_unlock (&catalog);
+    SetProtect (TRUE);
+    if (!dvo_catalog_save (&catalog, VERBOSE)) { fprintf (stderr, "ERROR: failed to save %s\n", catalog.filename); exit (1); }
+    if (!dvo_catalog_unlock (&catalog)) { fprintf (stderr, "ERROR: failed to unlock %s\n", catalog.filename); exit (1); }
+    SetProtect (FALSE);
     dvo_catalog_free (&catalog);
   }
