JRuby - Prevent JVM from exiting

LifeisHard

I'm calling a method from an external library that includes System.exit(), shutting down the JVM when the method is called. Is there a way to prevent the JVM created through JRuby to run System.exit() if encountered?

kares

you could install a SecurityManager for the JVM, using JRuby :

class SecurityManagerImpl < java.lang.SecurityManager

    def checkExit(status)
      raise java.lang.SecurityException.new("HALTED System.exit(#{status})") if status == 42
    end

    # optionally - disable all other checks from happening :
    superclass.instance_methods(false).select { |name| name.to_s.start_with?('check') }.each do |name|
      class_eval "def #{name}(*args) end" if name != :checkExit
    end

end

java.lang.System.setSecurityManager(SecurityManagerImpl.new)

now, all exit(42) calls will fail with a Java::JavaLang::SecurityException (HALTED System.exit(42)) which need to be handled up the call stack.

be aware that this is likely a very "hacky" work-around to have in place ...

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Prevent page from exiting

From Dev

Prevent a nodejs application from exiting

From Dev

Prevent container from exiting, conditionally

From Dev

How to prevent the NodeJS event loop from exiting?

From Dev

Prevent grep from exiting in case of nomatch

From Java

Mobaxterm: how to prevent ssh session from exiting?

From Dev

Promise prevent node process from exiting

From Dev

Prevent text selection from exiting a div

From Dev

Prevent grep from exiting in case of nomatch

From Dev

Prevent Emacs from exiting once the exit procedure has initiated?

From Dev

Prevent exit() in third-party function from exiting?

From Dev

how to prevent mocha from exiting process with status 1

From Dev

Prevent Vi from exiting with an error code when my fingers are fat

From Dev

How to prevent my threads from exiting before their work is done?

From Dev

Prevent WindowsService exiting

From Dev

Prevent jRuby on Rails app with Puma/IIS from falling asleep after a set amount of time

From Dev

Prevent exiting maximized window mode

From Dev

How to prevent programmatically started python script from exiting command prompt after error?

From Dev

How to prevent a Command Line Tool from exiting before asynchronous operation completes

From Dev

Unity3d editor: how to prevent changes from being undone upon exiting play mode?

From Dev

How to prevent from exiting MapReduce job when an Exception throwed in Elasitcsearch Hadoop

From Dev

What is the proper way to prevent a program from exiting after a user enters wrong input in Java?

From Dev

JVM not exiting until daemon thread not completed

From Dev

exiting from script

From Dev

Not exiting from shell script

From Dev

Prevent exiting the loop on runtime exception in Java

From Dev

How does one configure jruby JVM settings on Heroku?

From Dev

poll exiting immidiately from driver

From Dev

poll exiting immidiately from driver

Related Related

  1. 1

    Prevent page from exiting

  2. 2

    Prevent a nodejs application from exiting

  3. 3

    Prevent container from exiting, conditionally

  4. 4

    How to prevent the NodeJS event loop from exiting?

  5. 5

    Prevent grep from exiting in case of nomatch

  6. 6

    Mobaxterm: how to prevent ssh session from exiting?

  7. 7

    Promise prevent node process from exiting

  8. 8

    Prevent text selection from exiting a div

  9. 9

    Prevent grep from exiting in case of nomatch

  10. 10

    Prevent Emacs from exiting once the exit procedure has initiated?

  11. 11

    Prevent exit() in third-party function from exiting?

  12. 12

    how to prevent mocha from exiting process with status 1

  13. 13

    Prevent Vi from exiting with an error code when my fingers are fat

  14. 14

    How to prevent my threads from exiting before their work is done?

  15. 15

    Prevent WindowsService exiting

  16. 16

    Prevent jRuby on Rails app with Puma/IIS from falling asleep after a set amount of time

  17. 17

    Prevent exiting maximized window mode

  18. 18

    How to prevent programmatically started python script from exiting command prompt after error?

  19. 19

    How to prevent a Command Line Tool from exiting before asynchronous operation completes

  20. 20

    Unity3d editor: how to prevent changes from being undone upon exiting play mode?

  21. 21

    How to prevent from exiting MapReduce job when an Exception throwed in Elasitcsearch Hadoop

  22. 22

    What is the proper way to prevent a program from exiting after a user enters wrong input in Java?

  23. 23

    JVM not exiting until daemon thread not completed

  24. 24

    exiting from script

  25. 25

    Not exiting from shell script

  26. 26

    Prevent exiting the loop on runtime exception in Java

  27. 27

    How does one configure jruby JVM settings on Heroku?

  28. 28

    poll exiting immidiately from driver

  29. 29

    poll exiting immidiately from driver

HotTag

Archive