当前位置: 首页>>代码示例>>Java>>正文


Java SignalHandler.SIG_IGN属性代码示例

本文整理汇总了Java中sun.misc.SignalHandler.SIG_IGN属性的典型用法代码示例。如果您正苦于以下问题:Java SignalHandler.SIG_IGN属性的具体用法?Java SignalHandler.SIG_IGN怎么用?Java SignalHandler.SIG_IGN使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在sun.misc.SignalHandler的用法示例。


在下文中一共展示了SignalHandler.SIG_IGN属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testRaiseNoConsumer

@Test
static void testRaiseNoConsumer() {
    Signal signal = new Signal("INT");
    SignalHandler orig = null;
    try {
        orig = Signal.handle(signal, SignalHandler.SIG_DFL);
        printf("oldHandler: %s%n", orig);
        if (orig == SignalHandler.SIG_IGN) {
            // SIG_IGN for TERM means it cannot be handled
            return;
        }
        Signal.raise(signal);
        Assert.fail("Should have thrown IllegalArgumentException");
    } catch (IllegalArgumentException iae) {
        printf("IAE message: %s%n", iae.getMessage());
    } finally {
        // Restore original signal handler
        if (orig != null && signal != null) {
            Signal.handle(signal, orig);
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:SunMiscSignalTest.java

示例2: checkLastHandler

@Test()
static void checkLastHandler() {
    if (RUNNING_WITH_Xrs) {
        return;
    }
    Signal signal = new Signal("TERM");
    Handler h1 = new Handler();
    Handler h2 = new Handler();
    SignalHandler orig = Signal.handle(signal, h1);
    if (orig == SignalHandler.SIG_IGN) {
        // SIG_IGN for TERM means it cannot be handled
        return;
    }

    try {
        SignalHandler prev = Signal.handle(signal, h2);
        Assert.assertSame(prev, h1, "prev handler mismatch");

        prev = Signal.handle(signal, h1);
        Assert.assertSame(prev, h2, "prev handler mismatch");
    } finally {
        if (orig != null && signal != null) {
            Signal.handle(signal, orig);
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:SunMiscSignalTest.java

示例3: isDaemonThread

/**
 * The thread that runs the handler for sun.misc.Signal should be a
 * Daemon thread.
 */
@Test
static void isDaemonThread() throws InterruptedException {
    if (RUNNING_WITH_Xrs) {
        return;
    }
    Handler handler = new Handler();
    Signal signal = new Signal("INT");
    SignalHandler orig = Signal.handle(signal, handler);
    printf("oldHandler: %s%n", orig);
    if (orig == SignalHandler.SIG_IGN) {
        // SIG_IGN for INT means it cannot be handled
        return;
    }

    Signal.raise(signal);
    boolean handled = handler.semaphore()
            .tryAcquire(Utils.adjustTimeout(100L), TimeUnit.MILLISECONDS);
    if (!handled) {
        // For debug try again
        printf("Second try to see signal");
        handled = handler.semaphore()
                .tryAcquire(Utils.adjustTimeout(2L), TimeUnit.SECONDS);
    }
    Assert.assertEquals(handled, !RUNNING_WITH_Xrs,
            "raising s.m.Signal did not get a callback;");

    Assert.assertTrue(handler.wasDaemon(), "Thread.isDaemon running the handler; ");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:32,代码来源:SunMiscSignalTest.java

示例4: getOriginalSignalHandler

protected SignalHandler getOriginalSignalHandler(final Signal signal) {
  final SignalHandler handler = originalSignalHandlers.get(signal);
  return (handler == SignalHandler.SIG_DFL || handler == SignalHandler.SIG_IGN ? null : handler);
}
 
开发者ID:ampool,项目名称:monarch,代码行数:4,代码来源:GfshSignalHandler.java


注:本文中的sun.misc.SignalHandler.SIG_IGN属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。