tgravescs commented on a change in pull request #25047:
[WIP][SPARK-27371][CORE] Support GPU-aware resources scheduling in Standalone
URL: https://github.com/apache/spark/pull/25047#discussion_r308309171
##########
File path: core/src/main/scala/org/apache/spark/util/Utils.scala
##########
@@ -2547,6 +2567,27 @@ private[spark] object Utils extends Logging {
new File(path.getAbsolutePath + "." + UUID.randomUUID())
}
+ /**
+ * Given a process id, return true if the process is still running.
+ */
+ def isProcessRunning(pid: Int): Boolean = {
+ val process = executeCommand(Seq("kill", "-0", pid.toString))
+ process.waitFor(10, TimeUnit.SECONDS)
+ process.exitValue() == 0
+ }
+
+ /**
+ * Returns the pid of this JVM process.
+ */
+ def getProcessId: Int = {
+ try {
+ getProcessName().split("@")(0).toInt
Review comment:
good question, I suppose its possible but I would hope it wouldn't return
the PID of some other process. I would really hope it either throws an
exception or what I was really thinking was it doesn't come back formatted the
same.
Maybe we can compromise here and after the split check to make sure there
were 2 items.. ie it actually had an @ in it. If it didn't then we throw with
unexpected format.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]