Changeset: 9b9fa398de4b for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=9b9fa398de4b
Modified Files:
        clients/R/MonetDB.R/NEWS
        clients/R/MonetDB.R/R/control.R
Branch: embedded
Log Message:

R Client, no force-kill on Windows plus wait support


diffs (77 lines):

diff --git a/clients/R/MonetDB.R/NEWS b/clients/R/MonetDB.R/NEWS
--- a/clients/R/MonetDB.R/NEWS
+++ b/clients/R/MonetDB.R/NEWS
@@ -24,6 +24,8 @@ 1.0.0
 - Support for running MonetDB in embedded mode (MonetDBLite)
 - Support for monetdblite:/some/path URLs in dbConnect()
 - Fixed an off-by-one error in type conversion (Thanks, Kirill)
+- Not force-killing mserver when calling monetdb.server.stop on windows and 
wait support
+
 
 0.9.7
 - Fixed crash on Windows (Sorry, everyone)
diff --git a/clients/R/MonetDB.R/R/control.R b/clients/R/MonetDB.R/R/control.R
--- a/clients/R/MonetDB.R/R/control.R
+++ b/clients/R/MonetDB.R/R/control.R
@@ -67,40 +67,28 @@ monetdb.server.start <-
     
   }
 
-
-monetdb.server.stop <-
-  function( correct.pid, wait=TRUE ){
-    
-    if ( .Platform$OS.type == "unix" ) {
-      system(paste0("kill ",correct.pid))  
-      waittime <- 2
-      if (!wait) return(TRUE)
-      Sys.sleep(.5)
-      repeat {
-        psout <- system(paste0("ps ax | grep \"^", correct.pid, 
".*mserver5\""), ignore.stdout=T) 
-        if (psout != 0) break
-        message("Waiting ",waittime,"s for server shutdown (ESC or CTRL+C to 
abort)")
-        Sys.sleep(waittime)
-        waittime <- waittime * 2
-      }
-    } 
-    
-    if ( .Platform$OS.type == "windows" ) {
-      
-      # write the taskkill command line
-      taskkill.cmd <- 
-        paste( 
-          "taskkill" , 
-          "/PID" , 
-          correct.pid ,
-          "/F"
-        )
-      
-      # kill the same process that was loaded
-      system( taskkill.cmd )
-      
-    }
+# oh the humanity
+monetdb.server.stop <- function(correct.pid, wait=TRUE ){
+  correct.pid <- as.integer(correct.pid)
+  if (.Platform$OS.type == "windows")
+    system(paste0("taskkill /PID ", correct.pid))
+  else
+    system(paste0("kill ", correct.pid))
+  waittime <- 2
+  if (!wait) return(TRUE)
+  Sys.sleep(.5)
+  repeat {
+    stillrunning <- F
+    if (.Platform$OS.type == "windows")
+      stillrunning <- grepl("mserver5", system2('tasklist', c('/FI "PID eq ', 
correct.pid, '" /FO CSV'), stdout=T)[2])
+    else
+      stillrunning <- system(paste0("ps ax | grep \"^", correct.pid, 
".*mserver5\""), ignore.stdout=T) == 0
+    if (!stillrunning) break
+    message("Waiting ", waittime, "s for server shutdown (ESC or CTRL+C to 
abort)")
+    Sys.sleep(waittime)
+    waittime <- waittime * 2
   }
+}
 
 monetdb.server.setup <-
   function( 
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to