You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@groovy.apache.org by Merlin Beedell <MB...@cryoserver.com> on 2015/09/04 18:36:03 UTC

GroovyConsole System.exit() suggestion

I note that the useful GroovyConsole will exit if the script being run hits a System.exit().  This is understandable when the script runs in that same thread as the Console.  But it would be really useful to be able to run scripts in a separate thread to protect against exit() [and to display the exit value] and also for scripts with infinite loops that need to be killed!

And, maybe, it would also allow these scripts to obtain the 'console' object for keyboard input?

                Console cons = System.console()
                Boolean isWorking () {
                                if (!cons)
                                {
                                                println "Cannot open a console for input"  //always the case under GroovyConsole
                                }
                                return (cons != null)
                }
Merlin Beedell

RE: GroovyConsole System.exit() suggestion

Posted by Merlin Beedell <MB...@cryoserver.com>.
Well - this would help if it was part of the Console app.  I don't really want to pop this code in to each script just for testing purposes.

Furthermore, it would also be nice if the console could setup the args[] & stdin features.  This would mean:

Ø  Ability to pass parameters to scripts (to emulate a command line)

Ø  Pipe output of an o/s statement to the current script. [dir c:/ | <this script>].  The console would need to launch the o/s command etc.

..and so the wish list grows!!

Merlin Beedell

From: Schalk Cronjé [mailto:ysb33r@gmail.com]
Sent: 04 September 2015 18:07
To: users@groovy.incubator.apache.org
Subject: Re: GroovyConsole System.exit() suggestion


Does this - http://jroller.com/ethdsy/entry/disabling_system_exit - help ?

On 04/09/2015 17:36, Merlin Beedell wrote:
I note that the useful GroovyConsole will exit if the script being run hits a System.exit().  This is understandable when the script runs in that same thread as the Console.  But it would be really useful to be able to run scripts in a separate thread to protect against exit() [and to display the exit value] and also for scripts with infinite loops that need to be killed!

And, maybe, it would also allow these scripts to obtain the 'console' object for keyboard input?

                Console cons = System.console()
                Boolean isWorking () {
                                if (!cons)
                                {
                                                println "Cannot open a console for input"  //always the case under GroovyConsole
                                }
                                return (cons != null)
                }
Merlin Beedell




--

Schalk W. Cronjé

Twitter / Ello / Toeter : @ysb33r

Re: GroovyConsole System.exit() suggestion

Posted by James Northrop <ja...@orange.fr>.
Yes agree on this. It would be GR8 2 b able 2 disable system.exit() on  
the groovyConsole as i must do a song-and-dance to chg my source when  
testing.

On 4 Sep 2015, at 19:34, Keegan Witt wrote:

> I'd opened GROOVY-3963 a while back to start to separating Console  
> processes (though it doesn't propose separating it as much as you  
> did).  I'd love to have that feature, but haven't had time to think  
> about how we'd get around some of the complications.  Once they are  
> separated though, we could offer the option to disable exits with a  
> SecurityManager as Schalk's link discusses.
>
> -Keegan
>
> On Fri, Sep 4, 2015 at 1:07 PM, Schalk Cronjé <ys...@gmail.com>  
> wrote:
>
> Does this - http://jroller.com/ethdsy/entry/disabling_system_exit -  
> help ?
>
>
> On 04/09/2015 17:36, Merlin Beedell wrote:
>> I note that the useful GroovyConsole will exit if the script being  
>> run hits a System.exit().  This is understandable when the script  
>> runs in that same thread as the Console.  But it would be really  
>> useful to be able to run scripts in a separate thread to protect  
>> against exit() [and to display the exit value] and also for scripts  
>> with infinite loops that need to be killed!
>>
>>
>>
>> And, maybe, it would also allow these scripts to obtain the  
>> ‘console’ object for keyboard input?
>>
>>
>>
>>                 Console cons = System.console()
>>
>>                 Boolean isWorking () {
>>
>>                                 if (!cons)
>>
>>                                 {
>>
>>                                                 println "Cannot  
>> open a console for input"  //always the case under GroovyConsole
>>
>>                                 }
>>
>>                                 return (cons != null)
>>
>>                 }
>>
>> Merlin Beedell
>>
>
>
> -- 
> Schalk W. Cronjé
> Twitter / Ello / Toeter : @ysb33r
>


Re: GroovyConsole System.exit() suggestion

Posted by Keegan Witt <ke...@gmail.com>.
I'd opened GROOVY-3963 <https://issues.apache.org/jira/browse/GROOVY-3963> a
while back to start to separating Console processes (though it doesn't
propose separating it as much as you did).  I'd love to have that feature,
but haven't had time to think about how we'd get around some of the
complications.  Once they are separated though, we could offer the option
to disable exits with a SecurityManager as Schalk's link discusses.

-Keegan

On Fri, Sep 4, 2015 at 1:07 PM, Schalk Cronjé <ys...@gmail.com> wrote:

>
> Does this - http://jroller.com/ethdsy/entry/disabling_system_exit - help ?
>
>
> On 04/09/2015 17:36, Merlin Beedell wrote:
>
> I note that the useful GroovyConsole will exit if the script being run
> hits a System.exit().  This is understandable when the script runs in that
> same thread as the Console.  But it would be really useful to be able to
> run scripts in a separate thread to protect against exit() [and to display
> the exit value] and also for scripts with infinite loops that need to be
> killed!
>
>
>
> And, maybe, it would also allow these scripts to obtain the ‘console’
> object for keyboard input?
>
>
>
>                 Console cons = System.console()
>
>                 Boolean isWorking () {
>
>                                 if (!cons)
>
>                                 {
>
>                                                 println "Cannot open a
> console for input"  //always the case under GroovyConsole
>
>                                 }
>
>                                 return (cons != null)
>
>                 }
>
> Merlin Beedell
>
>
>
> --
> Schalk W. Cronjé
> Twitter / Ello / Toeter : @ysb33r
>
>

Re: GroovyConsole System.exit() suggestion

Posted by Schalk Cronjé <ys...@gmail.com>.
Does this - http://jroller.com/ethdsy/entry/disabling_system_exit - help ?

On 04/09/2015 17:36, Merlin Beedell wrote:
>
> I note that the useful GroovyConsole will exit if the script being run 
> hits a System.exit().  This is understandable when the script runs in 
> that same thread as the Console.  But it would be really useful to be 
> able to run scripts in a separate thread to protect against exit() 
> [and to display the exit value] and also for scripts with infinite 
> loops that need to be killed!
>
> And, maybe, it would also allow these scripts to obtain the ‘console’ 
> object for keyboard input?
>
>                 Console cons = System.console()
>
>                 Boolean isWorking () {
>
>                                 if (!cons)
>
>                                 {
>
> println "Cannot open a console for input"  //always the case under 
> GroovyConsole
>
>                                 }
>
>                                 return (cons != null)
>
>                 }
>
> Merlin Beedell
>


-- 
Schalk W. Cronjé
Twitter / Ello / Toeter : @ysb33r