Scott,

On Feb 14, 2008, at 11:06 AM, Chris Schneider wrote:
I've been tracking down a problem we're having running Resin 3.0.21 for integration testing (part of a Maven-based build) on our Mac OS X development machines. For some reason, Resin often doesn't shut down properly after the tests complete, leaving both the wrapper.pl and JVM processes running. (I understand that the wrapper.pl script has now been replaced by a Java watchdog process in Resin 3.1.x, but we're still using 3.0.21.) In this state, I'm also unable to terminate them via a "kill -15 <wrapperPID>" on the command line.

At 12:34 PM -0800 2/14/08, Scott Ferguson wrote:
Thanks. I've just updated this. The kill -9 section needs a $time = $kill_time;

Um, perhaps you're looking at a different version of the code, but the wrapper.pl in Resin 3.0.21 doesn't appear to need such a statement (because it doesn't need to loop, just do the kill -9 and terminate). Instead, I think the ($time < 0) expression is the problem (as I outlined in my original email - see below).

Please advise,

- Chris

As I understand it, when the wrapper.pl script receives an INT(2), KILL(9), QUIT(3), or TERM(15) signal it tries to let its child, the JVM process, die gracefully by closing the keepalive socket linking them. It waits for 60 seconds to see whether this works (note: $kill_time is 60):

    if ($child > 0) {
        $time = $kill_time;
        # let it die gracefully in 60 seconds
        while ($time-- > 0 and kill(0, $child)) {
            sleep(1);
        }

If the child is still running after 60 seconds, it tries the (somewhat platform-dependent and confusingly documented) kill(-$child) for another 60 seconds:

        if ($time <= 0) {
            $time = $kill_time;

            while ($time-- > 0 and kill(-$child)) {
        sleep(1);
            }
        }

If the child is still running after the second 60 seconds, it wants to try the more drastic kill(-9, $child):

        if ($time < 0) {
            print("Resin proc $child did not die, using kill -9");

            kill(-9, $child);
        }

    }

Unfortunately, I don't think that ($time < 0) check is ever going to return true, since the while ($time-- > 0 and ...) loop should terminate with $time equal to 0 if the 60 seconds run out. Note the difference between this check and the previous one.

Thus, my reading of wrapper.pl suggests that it will *never* try to kill the JVM process via kill -9, so if Perl's funky kill(-$child) thing doesn't work (doesn't seem to help on Mac OS X), then both the wrapper.pl script and the JVM will be left running.

Does the analysis above make sense?

--
------------------------
Chris Schneider
TransPac Software, Inc.
[EMAIL PROTECTED]
------------------------
_______________________________________________
resin-interest mailing list
resin-interest@caucho.com
http://maillist.caucho.com/mailman/listinfo/resin-interest

Reply via email to