I know how to "deamonize" a process (not to confused with Thread.setDaemon
). There are some answers here and here and I'm using my own perl wrapper, which works fine.
But what I'd like to get now, is the parent process waiting for the Java process until it says "OK", i.e., until it has really started successfully (not only process started, but everything up and running well).
I could indicate this by writing a file, binding to a socket or alike, but it's ugly. Out of the eight items on the deamonize list, I only need the following three in a slightly simplified form:
- Close standard input, standard output and standard error.
- Run in the background (i.e., fork)
- Ignore SIGHUP.
The first and last item can be done before process start, so only forking the process remains. Googling for "Java fork" is hopeless since the ForkJoinPool
exists. Before I get my hands dirty, I'd like to know if
- it's supported in Java 9 (then I'd simply wait)
- someone did it already using JNA and what problems they ran in
- there's a better solution
I don't care about Windows as it's for a Linux server.