Changeset 659a7a in git for Singular


Ignore:
Timestamp:
Nov 5, 2013, 12:50:56 PM (10 years ago)
Author:
Andreas Steenpass <steenpass@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
d600e1863951bfc5135d0138b61badb20b1ec70a
Parents:
8c982c34545a8ef6ec86afcbb224757c7dffcd0f
git-author:
Andreas Steenpass <steenpass@mathematik.uni-kl.de>2013-11-05 12:50:56+01:00
git-committer:
Andreas Steenpass <steenpass@mathematik.uni-kl.de>2013-11-06 13:20:27+01:00
Message:
chg: defer shutdown caused by SIGTERM if necessary
(cherry picked from commit a76a64e703bae29ffee8057ab2b16abb20f9158a)

Signed-off-by: Andreas Steenpass <steenpass@mathematik.uni-kl.de>

Conflicts:
	Singular/cntrlc.cc
	Singular/cntrlc.h
	Singular/misc_ip.cc
Location:
Singular
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • Singular/cntrlc.cc

    r8c982c3 r659a7a  
    3030#include <Singular/cntrlc.h>
    3131#include <Singular/feOpt.h>
     32#include <Singular/misc_ip.h>
    3233#include <Singular/si_signals.h>
    3334#include <Singular/links/silink.h>
     
    8889}
    8990
     91volatile BOOLEAN do_shutdown = FALSE;
     92volatile int defer_shutdown = 0;
     93
    9094void sig_term_hdl(int /*sig*/)
    9195{
    92   if (ssiToBeClosed_inactive)
    93   {
    94     ssiToBeClosed_inactive=FALSE;
    95     while (ssiToBeClosed!=NULL)
    96     {
    97       slClose(ssiToBeClosed->l);
    98       if (ssiToBeClosed==NULL) break;
    99       ssiToBeClosed=(link_list)ssiToBeClosed->next;
    100     }
    101     exit(1);
    102   }
    103   //else: we already shutting down: let's do m2_end ist work
     96  do_shutdown = TRUE;
     97  if (!defer_shutdown)
     98  {
     99    m2_end(1);
     100  }
    104101}
    105102
  • Singular/cntrlc.h

    r8c982c3 r659a7a  
    1919/* TRUE for child of a fork or started with --batch*/
    2020
     21/* for deferring the call of m2_end() in SIGTERM handler if necessary */
     22extern volatile BOOLEAN do_shutdown;
     23extern volatile int defer_shutdown;
     24
    2125#endif
  • Singular/misc_ip.cc

    r8c982c3 r659a7a  
    10441044*/
    10451045extern "C" {
     1046/* Note: We cannot use a mutex here because mutexes are not async-safe, but
     1047 * m2_end is called by sig_term_hdl(). Anyway, the race condition in the first
     1048 * few lines of m2_end() should not matter.
     1049 */
     1050volatile BOOLEAN m2_end_called = FALSE;
    10461051
    10471052void m2_end(int i)
    10481053{
    1049   fe_reset_input_mode();
    1050   #ifdef PAGE_TEST
    1051   mmEndStat();
    1052   #endif
    1053   fe_reset_input_mode();
    1054   if (ssiToBeClosed_inactive)
    1055   {
    1056     link_list hh=ssiToBeClosed;
    1057     while(hh!=NULL)
    1058     {
    1059       //Print("close %s\n",hh->l->name);
    1060       slPrepClose(hh->l);
    1061       hh=(link_list)hh->next;
    1062     }
    1063     ssiToBeClosed_inactive=FALSE;
    1064 
    1065     idhdl h = currPack->idroot;
    1066     while(h != NULL)
    1067     {
    1068       if(IDTYP(h) == LINK_CMD)
    1069       {
    1070         idhdl hh=h->next;
    1071         //Print("kill %s\n",IDID(h));
    1072         killhdl(h, currPack);
    1073         h = hh;
     1054  if (!m2_end_called)
     1055  {
     1056    m2_end_called = TRUE;
     1057    fe_reset_input_mode();
     1058#ifdef PAGE_TEST
     1059    mmEndStat();
     1060#endif
     1061    fe_reset_input_mode();
     1062    if (ssiToBeClosed_inactive)
     1063    {
     1064      link_list hh=ssiToBeClosed;
     1065      while(hh!=NULL)
     1066      {
     1067        //Print("close %s\n",hh->l->name);
     1068        slPrepClose(hh->l);
     1069        hh=(link_list)hh->next;
     1070      }
     1071      ssiToBeClosed_inactive=FALSE;
     1072
     1073      idhdl h = currPack->idroot;
     1074      while(h != NULL)
     1075      {
     1076        if(IDTYP(h) == LINK_CMD)
     1077        {
     1078          idhdl hh=h->next;
     1079          //Print("kill %s\n",IDID(h));
     1080          killhdl(h, currPack);
     1081          h = hh;
     1082        }
     1083        else
     1084        {
     1085          h = h->next;
     1086        }
     1087      }
     1088      hh=ssiToBeClosed;
     1089      while(hh!=NULL)
     1090      {
     1091        //Print("close %s\n",hh->l->name);
     1092        slClose(hh->l);
     1093        hh=ssiToBeClosed;
     1094      }
     1095    }
     1096    if (!singular_in_batchmode)
     1097    {
     1098      if (i<=0)
     1099      {
     1100        if (TEST_V_QUIET)
     1101        {
     1102          if (i==0)
     1103            printf("Auf Wiedersehen.\n");
     1104          else
     1105            printf("\n$Bye.\n");
     1106        }
     1107        //#ifdef sun
     1108        //  #ifndef __svr4__
     1109        //    _cleanup();
     1110        //    _exit(0);
     1111        //  #endif
     1112        //#endif
     1113        i=0;
    10741114      }
    10751115      else
    10761116      {
    1077         h = h->next;
    1078       }
    1079     }
    1080     hh=ssiToBeClosed;
    1081     while(hh!=NULL)
    1082     {
    1083       //Print("close %s\n",hh->l->name);
    1084       slClose(hh->l);
    1085       hh=ssiToBeClosed;
    1086     }
    1087   }
    1088   if (!singular_in_batchmode)
    1089   {
    1090     if (i<=0)
    1091     {
    1092       if (TEST_V_QUIET)
    1093       {
    1094         if (i==0)
    1095           printf("Auf Wiedersehen.\n");
    1096         else
    1097           printf("\n$Bye.\n");
    1098       }
    1099       //#ifdef sun
    1100       //  #ifndef __svr4__
    1101       //    _cleanup();
    1102       //    _exit(0);
    1103       //  #endif
    1104       //#endif
    1105       i=0;
    1106     }
    1107     else
    1108     {
    11091117        printf("\nhalt %d\n",i);
    1110     }
    1111   }
    1112   exit(i);
     1118      }
     1119    }
     1120    exit(i);
     1121  }
    11131122}
    11141123}
Note: See TracChangeset for help on using the changeset viewer.