Fork me on GitHub
#clojure
<
2024-02-07
>
onetom07:02:24

this upcoming clojure.java.process NS looks very nice so far, BUT i'd like it to be more debuggable. when i use process/exec i'd like to see what was the final, effective command line and environment variables of the executed process. to do that, i could switch to using process/start, so i can do (doto (-> :process ^ProcessHandle$Info .info .commandLine .get prn)), BUT then i would lose the rest of the process/exec functionality.

1
onetom07:02:48

and i still don't how to obtain the effective process environment, though it was already available during the use of the ProcessBuilder.

onetom08:02:15

here is a complete example, in case anyone wants to start looking into this question:

(-> (clojure.java.process/start
        {:out :inherit :err :inherit :env {"ASD" "123"}}
        "bash" "-c" "echo $ASD")
      (doto (-> :process ^java.lang.ProcessHandle$Info .info .commandLine .get prn)))

onetom08:02:09

so when my "production code" is just

(-> (clojure.java.process/exec
        {:out :inherit :err :inherit :env {"ASD" "123"}}
        "bash" "-c" "echo $ASD"))
what would be the least invasive way to modify this expression to obtain the command-line and process-environment values?

Alex Miller (Clojure team)13:02:09

Can you put this on http://ask.clojure.org and focus on the problem you’re trying to solve? What are you trying to debug and why?

👍 1
borkdude09:02:31

@U086D6TBN babashka.process returns a record with :cmd in it, FWIW:

$ bb -e '(:cmd (babashka.process/process "ls"))'
["ls"]

👍 1
vemv20:02:45

Sanity check... is it expected that a (proxy [Foo Bar] ,,, is not an instance of Bar ?

vemv20:02:11

(in-ns 'clj-http.conn-mgr)

(instance? ReuseableAsyncConnectionManager
           (proxy [PoolingNHttpClientConnectionManager ReuseableAsyncConnectionManager]
     [(make-ioreactor nil) nil (into-registry {}) nil nil 2.0
      java.util.concurrent.TimeUnit/SECONDS])) ;; => false

vemv20:02:43

ohhh scratch this, sorry for the noise. There's some sort of code reloading issue, since after a jvm restart that code returns true

hiredman20:02:24

https://ask.clojure.org/index.php/3352/proxy-super-threadsafe-should-made-safe-documented-unsafe is something to watch out for depending how complicated your proxy usage is

👍 1