Changeset 32cb7a in git for Singular/cntrlc.cc


Ignore:
Timestamp:
Oct 12, 2012, 5:18:39 PM (12 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'b4f17ed1d25f93d46dbe29e4b499baecc2fd51bb')
Children:
17874ed75ee295b8f839c9c6087da10a82e6ff2e
Parents:
b51d2ccd49597e776969d2543051d6119c88d59b
Message:
chg: handling of cntrl-c (from master: --cntrlc=?)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Singular/cntrlc.cc

    rb51d2c r32cb7a  
    373373#endif
    374374
    375 
    376375/*2
    377376* signal handler for SIGINT
    378377*/
     378int sigint_handler_cnt=0;
    379379void sigint_handler(int sig)
    380380{
     
    383383  if (fe_is_raw_tty) fe_temp_reset();
    384384  #endif /* HAVE_FEREAD */
     385  char default_opt=' ';
     386  if ((feOptSpec[FE_OPT_CNTRLC].value!=NULL)
     387      && ((char*)(feOptSpec[FE_OPT_CNTRLC].value))[0])
     388  { default_opt=((char*)(feOptSpec[FE_OPT_CNTRLC].value))[0]; }
    385389  loop
    386390  {
    387391    int cnt=0;
    388392    int c;
    389     if(singular_in_batchmode)
     393
     394    if (singular_in_batchmode)
    390395    {
    391396      c = 'q';
     397    }
     398    else if (default_opt!=' ')
     399    {
     400      c = default_opt;
    392401    }
    393402    else
     
    397406      if (feGetOptValue(FE_OPT_EMACS) == NULL)
    398407      {
    399         fputs("abort command(a), continue(c) or quit Singular(q) ?",stderr);fflush(stderr);
     408        fputs("abort after this command(a), abort immediately(r), print backtrace(b), continue(c) or quit Singular(q) ?",stderr);fflush(stderr);
    400409        c = fgetc(stdin);
    401410      }
     
    408417    switch(c)
    409418    {
    410       case 'q':
     419      case 'q': case EOF:
    411420                m2_end(2);
    412421      case 'r':
    413                 longjmp(si_start_jmpbuf,1);
     422                if (sigint_handler_cnt<3)
     423                {
     424                  sigint_handler_cnt++;
     425                  fputs("** Warning: Singular should be restarted as soon as possible **\n",stderr);
     426                  fflush(stderr);
     427                  longjmp(si_start_jmpbuf,1);
     428                }
     429                else
     430                {
     431                  fputs("** tried too often, try another possibility **\n",stderr);
     432                  fflush(stderr);
     433                }
     434                break;
    414435      case 'b':
    415436                VoiceBackTrack();
     
    418439                siCntrlc++;
    419440      case 'c':
    420                 if (feGetOptValue(FE_OPT_EMACS) == NULL) fgetc(stdin);
     441                if ((feGetOptValue(FE_OPT_EMACS) == NULL) && (default_opt!=' '))
     442                {
     443                  /* Read until a newline or EOF */
     444                  while (c != EOF && c != '\n') c = fgetc(stdin);
     445                }
    421446                si_set_signal(SIGINT ,(si_hdl_typ)sigint_handler);
    422447                return;
Note: See TracChangeset for help on using the changeset viewer.