--- a/src/Pure/System/isabelle_system.scala Tue Sep 13 23:06:52 2022 +0200
+++ b/src/Pure/System/isabelle_system.scala Wed Sep 14 10:46:47 2022 +0200
@@ -360,6 +360,23 @@
}
+ /* JVM shutdown hook */
+
+ def create_shutdown_hook(body: => Unit): Thread = {
+ val shutdown_hook = Isabelle_Thread.create(new Runnable { def run: Unit = body })
+
+ try { Runtime.getRuntime.addShutdownHook(shutdown_hook) }
+ catch { case _: IllegalStateException => }
+
+ shutdown_hook
+ }
+
+ def remove_shutdown_hook(shutdown_hook: Thread): Unit =
+ try { Runtime.getRuntime.removeShutdownHook(shutdown_hook) }
+ catch { case _: IllegalStateException => }
+
+
+
/** external processes **/
/* GNU bash */