CTRL-C just works fine in Karaf commands (including the one creating thread like log:tail).
So, your use case is about intercepting CTRL-C yourself, right ? What’s the use case you want to achieve ? Regards JB > Le 14 mars 2020 à 18:26, Mike Hummel <m...@mhus.de> a écrit : > > Looks like it's not possible to block the ctrl-c event. It's implemented in > felix gogo shell ans since every cmd (in a pipe) is executed in a separate > thread it's not clear witch one should do the interruption control > > Maybe the feature "IGNORE_INTERRUPS" should not be offered. > > But felix should inform the commands if the execution is canceled. For > example by checking for the Closeable interface and calling the close() > method. > > >> On 14. Mar 2020, at 11:09, Jean-Baptiste Onofre <j...@nanthrax.net >> <mailto:j...@nanthrax.net>> wrote: >> >> Hi Mike, >> >> Let me take a look. >> >> Thanks for the report. >> >> Regards >> JB >> >>> Le 14 mars 2020 à 09:03, Mike Hummel <m...@mhus.de <mailto:m...@mhus.de>> a >>> écrit : >>> >>> Hello, >>> >>> I did a little bit research for IGNORE_INTERRUPTS in the karaf sources. I >>> found in master and karaf-4.2.x the same results. >>> >>> The const is defined in 'Sessio'n and 'SessionProperties', but only used >>> from 'Session'. >>> >>> It is only used to enable the behaviour but never used to implement some >>> kind of behaviour. >>> >>> Is there someone how can can prove this? And what is the background for two >>> definitions of the same const? If I have the background I could look for a >>> fix. >>> >>> Just now I created KARAF-6645 to track the problem. >>> >>> Best Regards, >>> >>> Mike >>> >>> >>> >>> >>>> On 5. Mar 2020, at 09:53, Mike Hummel <m...@mhus.de <mailto:m...@mhus.de>> >>>> wrote: >>>> >>>> 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 <gno...@apache.org >>>>> <mailto:gno...@apache.org>> 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 <m...@mhus.de >>>>> <mailto:m...@mhus.de>> 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 >>>>> >>>> >>> >> >