Ticket #13908: 13908_no_SIGTERM.patch

File 13908_no_SIGTERM.patch, 4.7 KB (added by jdemeyer, 9 years ago)
  • c_lib/include/interrupt.h

    # HG changeset patch
    # User Jeroen Demeyer <jdemeyer@cage.ugent.be>
    # Date 1359370420 -3600
    # Node ID 853df0f6ac23ace09b54b7fd436f944c2e9a8e92
    # Parent  0815c5afd390872549e62d405f7f6ca5144626ae
    Don't handle SIGTERM
    
    diff --git a/c_lib/include/interrupt.h b/c_lib/include/interrupt.h
    a b  
    55
    66This code distinguishes between two kinds of signals:
    77
    8 (1) interrupt-like signals: SIGINT, SIGHUP, SIGTERM.  The word
     8(1) interrupt-like signals: SIGINT, SIGHUP.  The word
    99"interrupt" refers to any of these signals.  These need not be handled
    1010immediately, we might handle them at a suitable later time, outside of
    1111sig_block() and with the Python GIL acquired.  SIGINT raises a
    12 KeyboardInterrupt (as usual in Python), while SIGHUP and SIGTERM raise
     12KeyboardInterrupt (as usual in Python), while SIGHUP raises
    1313SystemExit, causing Python to exit.  The latter signals also redirect
    1414stdin from /dev/null, to cause interactive sessions to exit also.
    1515
     
    2626
    2727- Jeroen Demeyer (2010-10-03): almost complete rewrite (#9678)
    2828
    29 - Jeroen Demeyer (2013-01-11): handle SIGHUP and SIGTERM also (#13908)
     29- Jeroen Demeyer (2013-01-11): handle SIGHUP also (#13908)
    3030
    3131*/
    3232
     
    8989
    9090/*
    9191 * The signal handlers for Sage, one for interrupt-like signals
    92  * (SIGINT, SIGHUP, SIGTERM) and one for critical signals like SIGSEGV.
     92 * (SIGINT, SIGHUP) and one for critical signals like SIGSEGV.
    9393 *
    9494 * Inside sig_on() (i.e. when _signals.sig_on_count is positive), these
    9595 * handlers raise an exception and jump back to sig_on().
  • c_lib/src/interrupt.c

    diff --git a/c_lib/src/interrupt.c b/c_lib/src/interrupt.c
    a b  
    77
    88- Jeroen Demeyer (2010-10-03): almost complete rewrite (#9678)
    99
    10 - Jeroen Demeyer (2013-01-11): handle SIGHUP and SIGTERM also (#13908)
     10- Jeroen Demeyer (2013-01-11): handle SIGHUP also (#13908)
    1111
    1212*/
    1313
     
    5151 * initialized by setup_sage_signal_handler(). */
    5252static sigset_t default_sigmask;
    5353
    54 /* default_sigmask with SIGHUP, SIGINT, SIGALRM, SIGTERM added. */
     54/* default_sigmask with SIGHUP, SIGINT, SIGALRM added. */
    5555static sigset_t sigmask_with_sigint;
    5656
    5757/* Does this processor support the x86 EMMS instruction? */
     
    9494}
    9595
    9696
    97 /* Handler for SIGHUP, SIGINT, SIGTERM */
     97/* Handler for SIGHUP, SIGINT */
    9898void sage_interrupt_handler(int sig)
    9999{
    100100#if ENABLE_DEBUG_INTERRUPT
     
    311311    sigaddset(&sigmask_with_sigint, SIGHUP);
    312312    sigaddset(&sigmask_with_sigint, SIGINT);
    313313    sigaddset(&sigmask_with_sigint, SIGALRM);
    314     sigaddset(&sigmask_with_sigint, SIGTERM);
    315314
    316315    /* Install signal handlers */
    317316    struct sigaction sa;
     
    321320    sigaddset(&sa.sa_mask, SIGHUP);
    322321    sigaddset(&sa.sa_mask, SIGINT);
    323322    sigaddset(&sa.sa_mask, SIGALRM);
    324     sigaddset(&sa.sa_mask, SIGTERM);
    325323
    326324    sa.sa_handler = sage_interrupt_handler;
    327325    if (sigaction(SIGHUP, &sa, NULL)) {perror("sigaction"); exit(1);}
    328326    if (sigaction(SIGINT, &sa, NULL)) {perror("sigaction"); exit(1);}
    329     if (sigaction(SIGTERM, &sa, NULL)) {perror("sigaction"); exit(1);}
    330327    sa.sa_handler = sage_signal_handler;
    331328    /* Allow signals during signal handling, we have code to deal with
    332329     * this case. */
  • sage/tests/interrupt.pyx

    diff --git a/sage/tests/interrupt.pyx b/sage/tests/interrupt.pyx
    a b  
    793793
    794794
    795795########################################################################
    796 # Test SIGHUP and SIGTERM                                              #
     796# Test SIGHUP                                                          #
    797797########################################################################
    798798@return_exception
    799799def test_sighup(long delay = DEFAULT_DELAY):
     
    814814@return_exception
    815815def test_sigterm_and_sigint(long delay = DEFAULT_DELAY):
    816816    """
    817     Test a SIGTERM and a SIGINT arriving at essentially the same time.
     817    Test a SIGHUP and a SIGINT arriving at essentially the same time.
    818818    The SIGINT should be ignored and we should get a ``SystemExit``.
    819819
    820820    TESTS::
     
    825825    """
    826826    sig_on()
    827827    sig_block()
    828     signal_after_delay(SIGTERM, delay)
     828    signal_after_delay(SIGHUP, delay)
    829829    signal_after_delay(SIGINT, delay)
    830830    # 3 sleeps to ensure both signals arrive
    831831    ms_sleep(delay)
     
    851851    the child Sage process has properly started before we terminate it::
    852852
    853853        sage: while "GO" not in P.stdout.readline(): pass  # long time
    854         sage: os.kill(P.pid, SIGTERM)  # long time
     854        sage: os.kill(P.pid, SIGHUP)  # long time
    855855        sage: P.stdout.read()  # long time
    856856        '...Exiting spawned PARI/GP interpreter process...'
    857857        sage: P.wait()  # long time