Class CatchSignals

java.lang.Object
com.yahoo.yolean.system.CatchSignals

public class CatchSignals extends Object
  • Constructor Details

    • CatchSignals

      public CatchSignals()
  • Method Details

    • setup

      public static void setup(AtomicBoolean signalCaught)
      Sets up a signal handler for SIGTERM and SIGINT, where a given AtomicBoolean gets a true value when the signal is caught. Callers basically have two options for acting on the signal: They may choose to synchronize and wait() on this variable, and they will be notified when it changes state to true. To avoid problems with spurious wakeups, use a while loop and wait() again if the state is still false. As soon as the caller has been woken up and the state is true, the application should exit as soon as possible. They may also choose to poll the state of this variable. As soon as its state becomes true, the signal has been received, and the application should exit as soon as possible.
      Parameters:
      signalCaught - set to false initially, will be set to true when SIGTERM or SIGINT is caught.