It's not easy to say ... In 4.2.3 it's broken and in 4.1.x it was ok.

I testet the flag IGNORE_INTERRUPTS in 4.2.7 and it was not working as I 
imagine. I'm even not sure if the flag is exact what I want to do.


> On 4. Mar 2020, at 09:18, Guillaume Nodet <[email protected]> wrote:
> 
> 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] <mailto:[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
> 

Reply via email to