tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Funk <>
Subject Re: Scripted shutdown does not force JVM exit
Date Sat, 01 Jan 2005 13:38:03 GMT
The JVM exits when there are 0 non-daemon threads running. Tomcat itself 
shuts down fine with this constraint.

If the JVM does not shut down - it is due to bad 3rd party code which creates 
non-daemon threads and fail to detect a shutdown.

The UNIX scripts allow you to capture the process id of the JVM. This is done 
by setting the environment variable CATALINA_PID to be some file name. Then 
if you need to kill the JVM  - just "kill -9 `cat $CATALINA_PID`"

Calling System.exit() has been discussed on tomcat-dev and by vetoed.


Brett Randall wrote:

> I've noticed that Tomcat's scripted/orderly shutdown does not force the
> JVM to exit.  After running all lifecycle events, the main thread just
> "falls-through" rather than calling exit(0) to end the JVM.
> I'm wondering if this is intentional?  The result is that any
> application-spawned Thread-s that are not well managed (i.e. are allowed
> to continue to run or block after the context is removed) continue to
> run, and the JVM does not exit.
> This presents a problem for application deployers, when faced with
> applications that spawn threads and do not clean them up.  The only
> shutdown option in these cases is to send a SIGINTR to the JVM, as the
> scripted shutdown does not call exit.
> Is there a major problem with having the Tomcat shutdown sequence make a
> final call of System.exit(0), perhaps as a configurable option?  I think
> that if the intention is to shutdown the container, it makes sense that
> any (now defunct) threads that applications spawned also end.  I suppose
> that this would be a problem for anyone who runs Tomcat in a shared JVM.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message