class ExitTrappingSecurityManager extends SecurityManager {

	@Override
	public void checkExit(int status) {
		// Check if the existing SecurityManager has a policy.
		if (existingManager != null) {
			existingManager.checkExit(status);
		}
		// Unset ourselves to allow exiting.
		System.setSecurityManager(null);
		// Execute the desired behavior, e.g. forceful exit instead of proceeding with System.exit().
		onExitBehavior.accept(status);
	}

	public  ExitTrappingSecurityManager(Consumer<Integer> onExitBehavior, @Nullable SecurityManager existingManager);

}