I had a strange problem that I encountered when I wrote a script to run my local JBoss instance.
My code looks something like this:
with open("/var/run/jboss/jboss.pid", "wb") as f:
process = subprocess.Popen(["/opt/jboss/bin/standalone.sh", "-b=0.0.0.0"])
f.write(str(process.pid))
try:
process.wait()
except KeyboardInterrupt:
process.kill()
It should be pretty simple to understand, write the PID to the file during its launch, as soon as I get it KeyboardInterrupt, kill the child process.
The problem is that JBoss continues to run in the background after sending the kill signal, as it seems that the signal does not extend to the Java process started standalone.sh.
I like the idea of using Python to write system management scripts, but there are a lot of weird edge cases like this, if I wrote it in Bash, it would all just work ™.
, KeyboardInterrupt?