Could you be more specific about "older releases" ? Do you know in which release it broke ?
Le mer. 4 mars 2020 à 09:14, Mike Hummel <[email protected]> a écrit : > Hello, > > I try to break my karaf commands with Ctrl-C (e.g. by using > Thread.sleep()). In older releases this was no problem, but since the shell > starts every command in a separate thread the Cltr-C is also caught by gogo > and it will unlock the command from the console. > > I also tried this > > session.put(Session.IGNORE_INTERRUPTS, Boolean.TRUE); > > but it gets not the effect. > > Is there a way to recognise if the current command is separated from the > current gogo command line? > > A sample snipped: > > Object oldIgnoreInterrupts = > session.get(Session.IGNORE_INTERRUPTS); > try { > session.put(Session.IGNORE_INTERRUPTS, Boolean.TRUE); > return doExecute(this, cmd, parameters); > } finally { > session.put(Session.IGNORE_INTERRUPTS, oldIgnoreInterrupts); > } > > public Object doExecute(CmdShitYo base, String cmd, String[] > parameters) throws Exception { > if (cmd.equals("ctrl-c")) { > try { > while (true) { > System.out.println("Wait for Ctrl-C - off"); > MThread.sleep(3000); > } > } catch (InterruptedException e) { > System.out.println("Interrupted !!!!"); > } > } > } > > MThread: > public static void sleep(long _millisec) { > try { > Thread.sleep(_millisec); > } catch (InterruptedException e) { > log.i(e); > } > } > > This will output > > Wait for Ctrl-C - off > Wait for Ctrl-C - on > Wait for Ctrl-C - off > Wait for Ctrl-C - on > ... > > If I interrupt, it will be separated from gogo shell and iterate for ever. > - And I see the interrupted exception in the log. > > Thx, > > Mike -- ------------------------ Guillaume Nodet
