Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use ProcessHandleinstead of graalvm substitutions #24

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ def tmpDirBase =

class Library(val crossScalaVersion: String) extends CrossScalaModule with LibDaemonPublish {
def artifactName = "libdaemon"
def compileIvyDeps = super.compileIvyDeps() ++ Seq(
ivy"org.graalvm.nativeimage:svm:21.2.0"
)
def javacOptions = super.javacOptions() ++ Seq(
"--release",
"16"
Expand Down
7 changes: 0 additions & 7 deletions library/src/libdaemonjvm/internal/IsRunning.java

This file was deleted.

18 changes: 0 additions & 18 deletions library/src/libdaemonjvm/internal/IsRunningSubst.java

This file was deleted.

13 changes: 6 additions & 7 deletions library/src/libdaemonjvm/internal/LockProcess.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@ trait LockProcess {
object LockProcess {
class Default extends LockProcess {
Copy link
Author

@oyvindberg oyvindberg Feb 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this change likely means we could inline/remove the whole LockProcess trait, as well as change Int to Long. However, I choose to maintain bincompat instead and just do the minimum here

def pid(): Int =
Option((new Pid).get()).map(n => (n: Int)).getOrElse {
sys.error("Cannot get PID")
}
def isRunning(pid: Int): Boolean =
Option((new IsRunning).isRunning(pid)).map(b => (b: Boolean)).getOrElse {
Processes.isRunning(pid)
}
ProcessHandle.current().pid().toInt
def isRunning(pid: Int): Boolean = {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note that this interface doesnt distinguish "no process with that pid" from "there is a process with that pid but it's not alive".

I wonder if there is a practical usecase for forcefully destroying the latter?

val maybeHandle = ProcessHandle.of(pid)
if (maybeHandle.isEmpty) false
else maybeHandle.get.isAlive
}
}

def default: LockProcess =
Expand Down
16 changes: 0 additions & 16 deletions library/src/libdaemonjvm/internal/Pid.java

This file was deleted.

18 changes: 0 additions & 18 deletions library/src/libdaemonjvm/internal/PidSubst.java

This file was deleted.

32 changes: 0 additions & 32 deletions library/src/libdaemonjvm/internal/Processes.scala

This file was deleted.

Loading