In development for the PProf.jl package, we want to spawn a child process (
pprof -web ...), and have it run in the background, so that you can keep using julia with the webserver open. (This suggestion came from @gdkrmr, in a discourse post, and he’s added the functionality in a PR! )
I originally suggested to use
p = run(`...`, wait = false), which does indeed open the process in the background, and allow you to later kill it and restart it.
However, it appears that
wait=false also detaches the process, so that when you kill Julia, the process remains open. I can’t find any documentation confirming that, but it seems like it from my experience.
After some experimentation, I think this is the right way to open a process in the background without detaching:
p = open(pipeline(`...`)) # open process in background, kill if julia exits.
p = run(`...`, wait=false) # open process in background, and detach, so it stays alive if julia exits.
- Am I right about the difference between these two?
- Are there any other differences besides this difference that I should know about?
(And once we have good answers to those, I can add this info to the documentation: https://docs.julialang.org/en/v1/manual/running-external-programs/#Running-External-Programs-1)