2 Replies Latest reply on Nov 5, 2002 9:27 AM by tobias

    How to avoid CTRL-C shutdown

    sebaseba

      === Problem: ===

      JBoss adds a shutdown hook that listens to kill signals from the OS. On Solaris, some shells (in particular sh) seem to trigger a kill signal when pressing CTRL-C in a console, which then shuts down JBoss.

      In other words, pressing CTRL-C on the console from which JBoss was started shuts it down again. This happens even when JBoss is started as a background process / using nohup, and CTRL-C is used much later e.g. to get out of a tail -f.

      The same problem arises when telnetting into a Solaris box to start JBoss. Whenever the telnet session is terminated in any way (logging out, timeout etc.), JBoss shuts down again.

      === Solution: ===

      Christer suggested the following solution which works fine for me: Add the -Xrs switch to the java command in the startup script. This prevents JBoss from adding a shutdown hook - see http://java.sun.com/j2se/1.3/docs/tooldocs/win32/java.html for documentation on the switch.

      More details about problem and solution are in this thread:
      http://www.jboss.org/modules/bb/index.html?module=bb&op=viewtopic&t=forums/ thread also describes an alternative perl based solution to the problem.

      Hope this is helpful.
      /Sebastian

        • 1. Re: How to avoid CTRL-C shutdown
          datique

          The problem seems to be even worse than this. How can I ever close the shell and expect JBoss to run as a daemon? I have found a workaround by getting the sources for the java program from J2SDK 1.4.0 and patching it to become a daemon, so that it ignores signals and detaches from the controlling terminal. It seems to work, but I would like to know about simpler solutions. I can post my changes to the java launcher if someone cares.

          • 2. Re: How to avoid CTRL-C shutdown
            tobias

            Either use
            screen
            and detach or
            nohup sh run.sh &
            which is good enough for me.