Spawn a process in Java that survives a JVM shutdown

后端 未结 7 1776
滥情空心
滥情空心 2020-12-10 03:40

I need to spawn a process in Java (under Linux exclusively) that will continue to run after the JVM has exited. How can I do this?

Basically the Java app should sp

7条回答
  •  感情败类
    2020-12-10 03:56

    It does actually "just work", unless you're trying to be clever.

    My wrapped java.lang.Process was trying to capture the script's output, so when the JVM died, the script didn't have anywhere to send output so it just dies. If I don't try to capture the output, or the script doesn't generate any or redirects everything to a file or /dev/null, everything works as it should.

提交回复
热议问题