Fix up other exit points. Should stop process hangs for clean exits.

This commit is contained in:
cpw 2014-06-24 22:15:11 -04:00
parent 90ad27d985
commit 3dbe6ccded
1 changed files with 5 additions and 3 deletions

View File

@ -16,9 +16,11 @@ public class FMLSecurityManager extends SecurityManager {
String permName = perm.getName() != null ? perm.getName() : "missing";
if (permName.startsWith("exitVM"))
{
String callingClass = getClassContext()[4].getName();
// FML is allowed to call system exit
if (!callingClass.startsWith("cpw.mods.fml."))
Class<?>[] classContexts = getClassContext();
String callingClass = classContexts.length > 3 ? classContexts[4].getName() : "none";
String callingParent = classContexts.length > 4 ? classContexts[5].getName() : "none";
// FML is allowed to call system exit and the Minecraft applet (from the quit button)
if (!(callingClass.startsWith("cpw.mods.fml.") || ( "net.minecraft.client.Minecraft".equals(callingClass) && "net.minecraft.client.Minecraft".equals(callingParent)) || ("net.minecraft.server.dedicated.DedicatedServer".equals(callingClass) && "net.minecraft.server.MinecraftServer".equals(callingParent))))
{
throw new ExitTrappedException();
}