nathanmarz/storm — pull request #238 by ept (2012-05-30 21:19:55+00:00)
Title: Use exec instead of forked child process for JVM

Using os.system() for creating the JVM forks a child of the Python
process. This makes it difficult for process managers like daemontools
or runit to kill/restart the process at admins' command: the process
manager tracks the PID of the Python process instead of that of the JVM;
and terminating the Python process unfortunately doesn't kill its JVM
child.

Some process managers let you configure the number of times the service
forks, or try to detect forks, but it's a bit of a rabbit-hole. Better
to make the service not fork in the first place.

For that reason I've replaced the call to os.system() with os.execvp(),
which replaces the Python process with the JVM, and thus lets the
process manager track the right PID.

os.execvp() requires that you give command-line arguments as an array of
strings, rather than one long whitespace-separated string, so I had to
change some of the surrounding code accordingly. Note this has the
pleasant side-effect that Storm should now also run if you install it in
a directory that has spaces in its path name.