Question would be, do you need to interact with process after you run that from your Crystal code? if yes then go with Process.new
and keep hold of Process object, invoke Process#wait
in a separate fiber. This use case is useful if you are interacting with a process via pipes and need to do some kind of communication and at end of your program closure, you need to terminate that.
And if your code doesn’t need any other interaction with process object and all you need is just start a process then you can invoke Process.run
in a separate fiber.
Something like
proc = Process.new(command: "sleep 10000", shell: true)
spawn { proc.wait}
# continue with your work
# pass around proc object to some code which need to do some further handling
# invoking either close or terminate on proc object at end of your interaction or program closure
OR
spawn { Process.run(command: "sleep 10000", shell: true) }
# continue with your work
HIH