Is there a straightforward way of getting the generated executable's location at run time?
How would you define minimal startup time? Have you tested how much you can cut from startup time by using direct linking, AOT, removing metadata, etc?
(System/getProperty "user.dir") - What happens with that?
@chris441 He means the executable that is currently being executed. E.g. when you run
bb -e '(+ 1 2 3)', you want to see
/usr/local/bin/bb or so
Ah, got it
Someone in the GraalVM slack told me that Graal has an API for this
but I haven't found it
One use case for this is to have an
upgrade command so an executable can update itself (not sure if that's a good idea, but exploring the possibilities)
Does the answer need to be cross platform? What platform is the query on?
For unix there are PID-related ways to do this.
yes, cross platform
should be somewhere available
user=> (org.graalvm.nativeimage.ProcessProperties/getExecutableName) Execution error (Error) at org.graalvm.nativeimage.impl.ImageSingletonsSupport/checkInstalled (ImageSingletonsSupport.java:69). The class ImageSingletons can only be used when building native images, i.e., when using the native-image command.
should be able to run this within a graalvm native image
wow, the exec method looks interesting: https://www.graalvm.org/sdk/javadoc/index.html?org/graalvm/nativeimage/ProcessProperties.html
@lukaszkorecki That's what you asked recently ^
Yes, that's the one!
What is it called again when a process replaces itself with another process? This is what happens here ^
$ ./bb -e '(do (prn (org.graalvm.nativeimage.ProcessProperties/getProcessID)) (org.graalvm.nativeimage.ProcessProperties/exec (fs/path "/bin/bash") (into-array String [""])))' 28122 bash-3.2$ ps aux | grep 28122 borkdude 28124 0.0 0.0 4399112 904 s015 S+ 9:23PM 0:00.00 grep 28122 borkdude 28122 0.0 0.0 4431696 1600 s015 S 9:23PM 0:00.03 TERM_SESSION_ID=w2t2p0:5035ECFF-A5DD-4DF9-9A67-6C736151E9AF
Getting the executable name:
$ ./bb -e '(org.graalvm.nativeimage.ProcessProperties/getExecutableName)' "/Users/borkdude/Dropbox/dev/clojure/babashka/bb"