scholarsmate commented on code in PR #371:
URL: https://github.com/apache/daffodil-vscode/pull/371#discussion_r1048995145


##########
src/utils.ts:
##########
@@ -173,6 +173,19 @@ export async function executeScript(
   return terminal
 }
 
+export async function stopJavaProcess(processName: string) {
+  // Stop debugger if running
+  if (os.platform() === 'win32') {
+    // Windows stop debugger if already running
+    child_process.execSync('tskill java 2>nul 1>nul || echo "Java not 
running"')
+  } else {
+    // Linux/Mac stop debugger if already running and make sure script is 
executable
+    child_process.exec(
+      `kill -9 $(ps -ef | grep '${processName}' | grep 'jar' | awk '{ print $2 
}') || return 0`
+    ) // ensure debugger server not running and
+  }
+}

Review Comment:
   I'm not a fan of this technique to kill processes.  When we exec the server, 
we can store the process ID and send the kill signal to that PID.  I could be 
running some other java process or even some other Ωedit process on a different 
port and this code will just murder those processes as collateral damage.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to