Changeset: d61dcc675506 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/d61dcc675506
Modified Files:
        tools/merovingian/daemon/forkmserver.c
Branch: Jul2021
Log Message:

Don't kill already dead server; kill inherited server.
If the pid in the internal admin is -1, we already received notification
(SIGCHILD) that the process died, so silently return.
If the internal pid is 0 and the pid from looking at the file system is
greater than 0, presumably the server is running but was not started by
us.  In this case, attempt to terminate it anyway.

Also, if the kill system call fails, also report why it failed.


diffs (43 lines):

diff --git a/tools/merovingian/daemon/forkmserver.c 
b/tools/merovingian/daemon/forkmserver.c
--- a/tools/merovingian/daemon/forkmserver.c
+++ b/tools/merovingian/daemon/forkmserver.c
@@ -57,6 +57,12 @@ terminateProcess(char *dbname, pid_t pid
                return false;
        }
 
+       if (pid == -1) {
+               /* it's already dead */
+               msab_freeStatus(&stats);
+               return true;
+       }
+
        if (stats->pid != pid) {
                Mfprintf(stderr,
                        "strange, trying to kill process %lld to stop database 
'%s' "
@@ -65,8 +71,13 @@ terminateProcess(char *dbname, pid_t pid
                        dbname,
                        (long long int)pid
                );
-               msab_freeStatus(&stats);
-               return false;
+               if (stats->pid >= 1 && pid < 1) {
+                       /* assume the server was started by a previous 
merovingian */
+                       pid = stats->pid;
+               } else {
+                       msab_freeStatus(&stats);
+                       return false;
+               }
        }
        assert(stats->pid == pid);
 
@@ -114,8 +125,8 @@ terminateProcess(char *dbname, pid_t pid
                         "TERM signal\n", (long long int)pid, dbname);
        if (kill(pid, SIGTERM) < 0) {
                /* barf */
-               Mfprintf(stderr, "cannot send TERM signal to process (database 
'%s')\n",
-                                dbname);
+               Mfprintf(stderr, "cannot send TERM signal to process (database 
'%s'): %s\n",
+                                dbname, strerror(errno));
                msab_freeStatus(&stats);
                return false;
        }
_______________________________________________
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org

Reply via email to