src/jdk.internal.le/share/classes/jdk/internal/jline/NoInterruptUnixTerminal.java
changeset 53333 fd6de53a0d6e
parent 53332 ab474ef0a0ac
parent 53010 086dfcfc3731
child 53334 b94283cb226b
equal deleted inserted replaced
53332:ab474ef0a0ac 53333:fd6de53a0d6e
     1 /*
       
     2  * Copyright (c) 2002-2016, the original author or authors.
       
     3  *
       
     4  * This software is distributable under the BSD license. See the terms of the
       
     5  * BSD license in the documentation provided with this software.
       
     6  *
       
     7  * http://www.opensource.org/licenses/bsd-license.php
       
     8  */
       
     9 package jdk.internal.jline;
       
    10 
       
    11 // Based on Apache Karaf impl
       
    12 
       
    13 /**
       
    14  * Non-interruptible (via CTRL-C) {@link UnixTerminal}.
       
    15  *
       
    16  * @since 2.0
       
    17  */
       
    18 public class NoInterruptUnixTerminal
       
    19     extends UnixTerminal
       
    20 {
       
    21     private String intr;
       
    22 
       
    23     public NoInterruptUnixTerminal() throws Exception {
       
    24         super();
       
    25     }
       
    26 
       
    27     @Override
       
    28     public void init() throws Exception {
       
    29         super.init();
       
    30         intr = getSettings().getPropertyAsString("intr");
       
    31         if ("<undef>".equals(intr)) {
       
    32             intr = null;
       
    33         }
       
    34         if (intr != null) {
       
    35             getSettings().undef("intr");
       
    36         }
       
    37     }
       
    38 
       
    39     @Override
       
    40     public void restore() throws Exception {
       
    41         if (intr != null) {
       
    42             getSettings().set("intr", intr);
       
    43         }
       
    44         super.restore();
       
    45     }
       
    46 }