Changeset bdda8c2 in git


Ignore:
Timestamp:
Apr 9, 2013, 4:39:42 PM (9 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', '5bec8f88c9ee2573d328cf7c3aff2bcb301d2395')
Children:
2d5ff537ab672bcbb2ca73df6830672f38b1ea63
Parents:
bc0d32def5d3461a77eed40c1e1a3d254811858a
Message:
add: handling signals in system calls, p2
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • Singular/cntrlc.cc

    rbc0d32 rbdda8c2  
    143143     fprintf(stderr, "Unable to init signal %d ... exiting...\n", sig);
    144144  }
    145 #ifdef HAVE_SIGINTERRUPT
    146   siginterrupt(sig, 0);
     145  si_siginterrupt(sig, 0);
    147146  /*system calls will be restarted if interrupted by  the  specified
    148147   * signal sig.  This is the default behavior in Linux.
    149148   */
    150 #endif
    151149#else
    152150  struct sigaction new_action,old_action;
     
    159157    new_action.sa_flags = SA_RESTART;
    160158
    161   int r=sigaction (sig, &new_action, &old_action);
     159  int r=si_sigaction (sig, &new_action, &old_action);
    162160  si_hdl_typ retval=(si_hdl_typ)old_action.sa_handler;
    163161  if (r == -1)
     
    503501  if (pid == 0)
    504502  {
    505     close (0); dup2 (in_fd[0],0);   /* set the stdin to the in pipe */
    506     close (1); dup2 (out_fd[1],1);  /* set the stdout to the out pipe */
    507     close (2); dup2 (out_fd[1],2);  /* set the stderr to the out pipe */
     503    si_close (0); si_dup2 (in_fd[0],0);   /* set the stdin to the in pipe */
     504    si_close (1); si_dup2 (out_fd[1],1);  /* set the stdout to the out pipe */
     505    si_close (2); si_dup2 (out_fd[1],2);  /* set the stderr to the out pipe */
    508506
    509507    execvp (args[0], args);      /* exec gdb */
     
    520518  FD_SET (out_fd[0], &fdset);
    521519
    522   write (in_fd[1], "backtrace\n", 10);
    523   write (in_fd[1], "p si_stop_stack_trace_x = 0\n", 28);
    524   write (in_fd[1], "quit\n", 5);
     520  si_write (in_fd[1], "backtrace\n", 10);
     521  si_write (in_fd[1], "p si_stop_stack_trace_x = 0\n", 28);
     522  si_write (in_fd[1], "quit\n", 5);
    525523
    526524  index = 0;
     
    533531    tv.tv_usec = 0;
    534532
    535     sel = select (FD_SETSIZE, &readset, NULL, NULL, &tv);
     533    sel = si_select (FD_SETSIZE, &readset, NULL, NULL, &tv);
    536534    if (sel == -1)
    537535      break;
     
    539537    if ((sel > 0) && (FD_ISSET (out_fd[0], &readset)))
    540538    {
    541       if (read (out_fd[0], &c, 1))
     539      if (si_read (out_fd[0], &c, 1))
    542540      {
    543541        switch (state)
     
    570568  }
    571569
    572   close (in_fd[0]);
    573   close (in_fd[1]);
    574   close (out_fd[0]);
    575   close (out_fd[1]);
     570  si_close (in_fd[0]);
     571  si_close (in_fd[1]);
     572  si_close (out_fd[0]);
     573  si_close (out_fd[1]);
    576574  m2_end(0);
    577575}
  • Singular/fehelp.cc

    rbc0d32 rbdda8c2  
    2323
    2424#include <findexec/omFindExec.h>
     25
     26#include <Singular/si_signals.h>
    2527
    2628#include "ipid.h"
     
    510512        hentry->url[i] = '\0';
    511513
    512         if (fscanf(fd, "%ld\n", &(hentry->chksum)) != 1)
     514        if (si_fscanf(fd, "%ld\n", &(hentry->chksum)) != 1)
    513515        {
    514516          hentry->chksum = -1;
     
    638640  if (fd == NULL) return 0;
    639641  memset(index_key,0,MAX_HE_ENTRY_LENGTH);
    640   while (fscanf(fd, "%[^\t]\t%*[^\n]\n", index_key) == 1)
     642  while (si_fscanf(fd, "%[^\t]\t%*[^\n]\n", index_key) == 1)
    641643  {
    642644    if ((index_key[MAX_HE_ENTRY_LENGTH-1]!='\0'))
     
    12201222  {
    12211223    // char* dummy=fgets(buffer, BUF_LEN, index); /* */
    1222     (void)sscanf(buffer, "Node:%[^\177]\177%ld\n", Index, &offset);
     1224    (void)si_sscanf(buffer, "Node:%[^\177]\177%ld\n", Index, &offset);
    12231225    for(p=Index; *p; p++) *p = tolow(*p);/* */
    12241226    (void)strcat(Index, " ");
  • Singular/fereadl.c

    rbc0d32 rbdda8c2  
    195195      #endif
    196196      /* OB: why this ? HS: char t_buf[128] does not work with glibc2 systems */
    197       char *t_buf=(char *)omAlloc(128); 
     197      char *t_buf=(char *)omAlloc(128);
    198198      /*char t_buf[128];*/
    199199      char *temp;
     
    325325    /* check for CSI */
    326326    c='\0';
    327     read (STDIN_FILENO, &c, 1);
     327    while((-1 == read (STDIN_FILENO, &c, 1)) && (errno == EINTR));
    328328    if (c == '[')
    329329    {
    330330      /* get command character */
    331331      c='\0';
    332       read (STDIN_FILENO, &c, 1);
     332      while((-1 == read (STDIN_FILENO, &c, 1)) && (errno == EINTR));
    333333      switch (c)
    334334      {
     
    415415          tv.tv_sec = 0;
    416416          tv.tv_usec = 0;
    417           #ifdef hpux
    418             sel = select (STDIN_FILENO+1, (int *)fdset.fds_bits, NULL, NULL, &tv);
    419           #else
    420             sel = select (STDIN_FILENO+1, &fdset, NULL, NULL, &tv);
    421           #endif
     417          do
     418          {
     419            sel = select (STDIN_FILENO+1,
     420#ifdef hpux
     421                          (int *)fdset.fds_bits,
     422#else
     423                          &fdset,
     424#endif
     425                          NULL, NULL, &tv);
     426          } while( (sel == -1) && (errno == EINTR) );
    422427          if (sel==0)
    423428            fe_temp_reset();
     
    770775    if (fe_rl_hdl==NULL) { return 1;}
    771776
    772     fe_filename_completion_function= 
     777    fe_filename_completion_function=
    773778      dynl_sym(fe_rl_hdl, "filename_completion_function");
    774779    if (fe_filename_completion_function==NULL) { res=3; break; }
     
    825830extern int history_total_bytes();
    826831extern int write_history (const char *);
    827 #endif   
     832#endif
    828833void fe_reset_input_mode ()
    829834{
  • Singular/links/semaphore.c

    rbc0d32 rbdda8c2  
    77
    88#include <kernel/mod2.h>
     9#include <Singular/si_signals.h>
    910
    1011#ifdef HAVE_SIMPLEIPC
     
    6667{
    6768  if ((id<0) || (id >= SIPC_MAX_SEMAPHORES) || (semaphore[id]==NULL))  return -1;
    68   sem_wait(semaphore[id]);
     69  si_sem_wait(semaphore[id]);
    6970  return 1;
    7071}
     
    7374{
    7475  if ((id<0) || (id >= SIPC_MAX_SEMAPHORES) || (semaphore[id]==NULL))  return -1;
    75   return !sem_trywait(semaphore[id]);
     76  return !si_sem_trywait(semaphore[id]);
    7677}
    7778
  • Singular/links/silink.cc

    rbc0d32 rbdda8c2  
    3131#include <Singular/links/ssiLink.h>
    3232#include <Singular/links/pipeLink.h>
     33#include <Singular/si_signals.h>
    3334#include "feOpt.h"
    3435
     
    159160  {
    160161    struct stat buf;
    161     if (lstat(l->name,&buf)==0) return "yes";
     162    if (si_lstat(l->name,&buf)==0) return "yes";
    162163    else return "no";
    163164  }
  • Singular/links/ssiLink.cc

    rbc0d32 rbdda8c2  
    199199      {
    200200        mpz_t tmp;
    201         mpz_init_set_si(tmp,nn);
     201        mpz_init_set_si(tmp,nn);
    202202        fputs("8 ",d->f_write);
    203203        mpz_out_str (d->f_write,32, tmp);
    204204        fputc(' ',d->f_write);
    205         mpz_clear(tmp);
     205        mpz_clear(tmp);
    206206      }
    207207      #endif
     
    491491         mpz_init(((number_dummy)n)->z);
    492492         mpz_init(((number_dummy)n)->n);
    493         s_readmpz_base (d->f_read,((number_dummy)n)->z, 32);
    494         s_readmpz_base (d->f_read,((number_dummy)n)->n, 32);
     493        s_readmpz_base (d->f_read,((number_dummy)n)->z, 32);
     494        s_readmpz_base (d->f_read,((number_dummy)n)->n, 32);
    495495         ((number_dummy)n)->s=sub_type-5;
    496496         return n;
     
    500500         number n=(number)omAlloc0(sizeof(snumber_dummy));
    501501         mpz_init(((number_dummy)n)->z);
    502         s_readmpz_base (d->f_read,((number_dummy)n)->z, 32);
     502        s_readmpz_base (d->f_read,((number_dummy)n)->z, 32);
    503503         ((number_dummy)n)->s=sub_type=3; /*subtype-5*/
    504504         return n;
     
    982982        char* cli_host = (char*)omAlloc(256);
    983983        char* path = (char*)omAlloc(1024);
    984         int r = sscanf(l->name,"%255[^:]:%s",cli_host,path);
     984        int r = si_sscanf(l->name,"%255[^:]:%s",cli_host,path);
    985985        if(r == 0)
    986986        {
     
    10391039        struct hostent *server;
    10401040
    1041         sscanf(l->name,"%255[^:]:%d",host,&portno);
     1041        si_sscanf(l->name,"%255[^:]:%d",host,&portno);
    10421042        //Print("connect to host %s, port %d\n",host,portno);mflush();
    10431043        if (portno!=0)
     
    13011301    case 19: res->rtyp=BIGINTMAT_CMD;
    13021302             res->data=ssiReadBigintmat(d);
    1303              break;
     1303             break;
    13041304    case 20: ssiReadBlackbox(res,l);
    13051305             break;
  • Singular/misc_ip.cc

    rbc0d32 rbdda8c2  
    1515#include "config.h"
    1616#include <kernel/mod2.h>
     17#include <Singular/si_signals.h>
    1718
    1819#ifdef HAVE_FACTORY
     
    10271028int singular_fstat(int fd, struct stat *buf)
    10281029{
    1029   return fstat(fd,buf);
     1030  return si_fstat(fd,buf);
    10301031}
    10311032
  • findexec/feFopen.cc

    rbc0d32 rbdda8c2  
    55#include <sys/stat.h>
    66#include <unistd.h>
     7#include <errno.h>
    78
    89#include "config.h"
     
    9798  {
    9899    struct stat statbuf;
    99     if ((stat(path,&statbuf)==0)
     100    int res = -1;
     101    do
     102    {
     103      res = stat(path,&statbuf);
     104    } while((res < 0) and (errno == EINTR));
     105    if ((res == 0)
    100106    && (S_ISREG(statbuf.st_mode)))
    101107      f = myfopen(path,mode);
  • libpolys/coeffs/ffields.cc

    rbc0d32 rbdda8c2  
    2222#include <string.h>
    2323#include <math.h>
     24#include <errno.h>
    2425
    2526BOOLEAN nfGreaterZero (number k, const coeffs r);
     
    225226{
    226227  assume(i==1);
    227  
     228
    228229  if( i == 1 )
    229230    return (number)1;
     
    655656    /*this field is already set*/  return;
    656657  int i=0;
    657  
    658   while ((fftable[i]!=c) && (fftable[i]!=0)) 
     658
     659  while ((fftable[i]!=c) && (fftable[i]!=0))
    659660    i++;
    660  
     661
    661662  if (fftable[i]==0)
    662663  {
     
    693694    }
    694695    int q;
    695     sscanf(buf,"%d %d",&r->m_nfCharP,&q);
     696    int res = -1;
     697    do
     698    {
     699      res = sscanf(buf,"%d %d",&r->m_nfCharP,&q);
     700    }
     701    while((res < 0) and (errno == EINTR));
     702
    696703    nfReadMipo(buf);
    697704    r->m_nfCharQ1=r->m_nfCharQ-1;
     
    829836
    830837  const int P = n_NumberOfParameters(r);
    831  
     838
    832839  for( int i = 1; i <= P; i++ )
    833     if (p[i-1] != NULL) 
     840    if (p[i-1] != NULL)
    834841      omFree( (ADDRESS)p[i-1] );
    835  
    836   omFreeSize((ADDRESS)p, P * sizeof(char*)); 
     842
     843  omFreeSize((ADDRESS)p, P * sizeof(char*));
    837844}
    838845
     
    865872  //r->cfRePart = ndCopy;
    866873  //r->cfImPart = ndReturn0;
    867  
     874
    868875  r->cfWriteLong = nfWriteLong;
    869876  r->cfInit_bigint = nlModP;
     
    884891  // debug stuff
    885892  r->cfCoeffWrite=nfCoeffWrite;
    886    
     893
    887894  r->cfParDeg = nfParDeg;
    888895
     
    890897  r->cfDBTest=nfDBTest;
    891898#endif
    892  
     899
    893900  // the variables:
    894901  r->nNULL = (number)0;
     
    900907
    901908  const char * name = p->GFPar_name;
    902  
     909
    903910  r->m_nfCharQ = 0;
    904911  r->m_nfCharP = p->GFChar;
     
    913920  assume( pParameterNames != NULL );
    914921  assume( pParameterNames[0] != NULL );
    915  
     922
    916923  r->pParameterNames = pParameterNames;
    917924  // NOTE: r->m_nfParameter was replaced by n_ParameterNames(r)[0]
     
    937944  }
    938945
    939   const double check= log ((double) (p->GFChar)); 
     946  const double check= log ((double) (p->GFChar));
    940947
    941948  if( (p->GFDegree * check) > sixteenlog2 )
     
    950957
    951958  nfReadTable(c, r);
    952  
     959
    953960  if( r->m_nfPlus1Table == NULL )
    954961  {
     
    958965    return TRUE;
    959966  }
    960  
    961  
     967
     968
    962969  assume (r -> m_nfCharQ > 0);
    963970
    964   r->ch = r->m_nfCharP; 
     971  r->ch = r->m_nfCharP;
    965972  assume( r->m_nfPlus1Table != NULL );
    966  
     973
    967974  return FALSE;
    968  
     975
    969976}
    970977
     
    981988    char *s=StringEndS(); PrintS(s); omFree(s);
    982989  }
    983   else PrintS("//   minpoly        : ...\n"); 
     990  else PrintS("//   minpoly        : ...\n");
    984991}
    985992
  • libpolys/polys/mod_raw.cc

    rbc0d32 rbdda8c2  
    1616#include <ctype.h>
    1717#include <sys/stat.h>
     18#include <errno.h>
    1819
    1920
     
    3940char* si_bultin_libs[]={ SI_FOREACH_BUILTIN(SI_BUILTIN_LIBSTR)  NULL };
    4041
    41 #undef SI_BUILTIN_LIBSTR 
     42#undef SI_BUILTIN_LIBSTR
    4243
    4344lib_types type_of_LIB(char *newlib, char *libnamebuf)
     
    4546  const unsigned char mach_o[]={0xfe,0xed,0xfa,0xce,0};
    4647  const unsigned char mach_O[]={0xce,0xfa,0xed,0xfe,0};
    47    
     48
    4849  const unsigned char mach_o64[]={0xfe,0xed,0xfa,0xcf,0};
    4950  const unsigned char mach_O64[]={0xcf,0xfa,0xed,0xfe,0};
    50    
     51
    5152  int i=0;
    5253  while(si_bultin_libs[i]!=NULL)
     
    6263  struct stat sb;
    6364  int nbytes = 0;
    64   // int ret;
     65  int ret;
    6566  lib_types LT=LT_NONE;
    6667
    6768  FILE * fp = feFopen( newlib, "r", libnamebuf, FALSE );
    68   /*ret =*/ (void) stat(libnamebuf, &sb);
     69
     70  do
     71  {
     72    ret = stat(libnamebuf, &sb);
     73  } while((ret < 0) and (errno == EINTR));
    6974
    7075  if (fp==NULL)
Note: See TracChangeset for help on using the changeset viewer.