public static void onProcessExited ( Process process , Listener < Integer > exitValueListener ) { Application app = LCCore . getApplication ( ) ; Mutable < Thread > mt = new Mutable <> ( null ) ; Thread t = app . getThreadFactory ( ) . newThread ( ( ) -> { try { exitValueListener . fire ( Integer . valueOf ( process . waitFor ( ) ) ) ; } catch ( InterruptedException e ) { /* ignore and quit */ } app . interrupted ( mt . get ( ) ) ; } ) ; mt . set ( t ) ; t . setName ( "Waiting for process to exit" ) ; t . start ( ) ; app . toInterruptOnShutdown ( t ) ; }
Create a thread that wait for the given process to end and call the given listener .