]> SAFE projects GIT repository - jmp/mailleur/commitdiff
sorter is now locking when running in background
authorJean-Marc Pigeon (Delson) <jmp@safe.ca>
Sun, 22 Jun 2025 12:31:37 +0000 (08:31 -0400)
committerJean-Marc Pigeon (Delson) <jmp@safe.ca>
Sun, 22 Jun 2025 12:31:37 +0000 (08:31 -0400)
app/sorter.c

index 76784a1d47f58c88f9a9e513403fa34ebf3f1ae0..8c6ecfda3c899bd593533a5d2c280ec5950cedd0 100644 (file)
 #include       "unisig.h"
 #include       "geseml.h"
 
+/*
+\f
+*/
+/********************************************************/
+/*                                                     */
+/*     Procedure to lock application if NOT in         */
+/*      foreground mode.                                */
+/*                                                     */
+/********************************************************/
+static void dolockunlock(_Bool locking)
+
+{
+if (foreground==false) {
+  if (prc_locking(appname,true,5)==false) {
+    switch (locking) {
+      case true   :
+        (void) rou_alert(0,"Unable to LOCK %s usage (system?)",appname);
+        break;
+      case false   :
+        (void) rou_alert(0,"Unable to UNLOCK %s usage (system?)",appname);
+        break;
+      }
+    }
+  }
+}
+/*
+\f
+*/
 /********************************************************/
 /*                                                     */
 /*     procedure to scan all files                     */
@@ -126,12 +154,15 @@ while (proceed==true) {
       (void) sig_modeunisig(true);
       (void) sig_trapsignal(true,sig_alrm);
       (void) rou_loadconfig(config,true);
+      (void) dolockunlock(false);
+      break;
+    case 2      :       //checking if we need to go background
       if (foreground==false) {
         if (prc_divedivedive()!=0)
           phase=999;    //direct exit
         }
       break;
-    case 2      :       //check about signal process
+    case 3      :       //check about signal process
       (void) sleep(TSLEEP);
       if (hangup==true) {
         (void) rou_alert(0,"%s got hangup signal",OPEP);
@@ -142,17 +173,18 @@ while (proceed==true) {
         phase=999;      //exiting loop
         }
       break;
-    case 3      :       //Scanning all ".trans" file             
+    case 4      :       //Scanning all ".trans" file             
       (void) scantrans(EXTRANS,true);
       break;
-    case 4      :       //Scanning all ".done" file             
+    case 5      :       //Scanning all ".done" file             
       (void) scantrans(EXDONE,false);
       break;
-    case 5      :       //one shot deal??
+    case 6      :       //one shot deal??
       if (foreground==false)
-        phase=1;       //restarting
+        phase=2;       //restarting
       break;
     default     :       //end of task
+      (void) dolockunlock(false);
       params=par_freeparams(params);
       (void) rou_loadconfig(config,false);
       (void) sig_trapsignal(false,sig_alrm);