Is it possible to double-fork a process in Java?

南笙酒味 提交于 2019-12-05 22:32:51

You will need to write a small C or C++ program to do the extra fork, setsid, all that stuff.

To make your life easier with this, you essentially need to disconnect the application from the shell by closing the input / output streams that are implicitly connected to the current terminal.

To make this simpler fro yourself, have a look at the akuma project. This would be a cleaner solution in plain Java without any need for C wrappers.

Here is a blog post discussing it.

You don't actually need to "double fork" in order to do this, only a single fork is necessary. Then the child should close stdin, out, error and start a new session.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!