Index: Singular/cntrlc.cc
===================================================================
--- Singular/cntrlc.cc	(revision bc0d32def5d3461a77eed40c1e1a3d254811858a)
+++ Singular/cntrlc.cc	(revision bdda8c2a271e7650c11462d22c70cd15d21d34f1)
@@ -143,10 +143,8 @@
      fprintf(stderr, "Unable to init signal %d ... exiting...\n", sig);
   }
-#ifdef HAVE_SIGINTERRUPT
-  siginterrupt(sig, 0);
+  si_siginterrupt(sig, 0);
   /*system calls will be restarted if interrupted by  the  specified
    * signal sig.  This is the default behavior in Linux.
    */
-#endif
 #else
   struct sigaction new_action,old_action;
@@ -159,5 +157,5 @@
     new_action.sa_flags = SA_RESTART;
 
-  int r=sigaction (sig, &new_action, &old_action);
+  int r=si_sigaction (sig, &new_action, &old_action);
   si_hdl_typ retval=(si_hdl_typ)old_action.sa_handler;
   if (r == -1)
@@ -503,7 +501,7 @@
   if (pid == 0)
   {
-    close (0); dup2 (in_fd[0],0);   /* set the stdin to the in pipe */
-    close (1); dup2 (out_fd[1],1);  /* set the stdout to the out pipe */
-    close (2); dup2 (out_fd[1],2);  /* set the stderr to the out pipe */
+    si_close (0); si_dup2 (in_fd[0],0);   /* set the stdin to the in pipe */
+    si_close (1); si_dup2 (out_fd[1],1);  /* set the stdout to the out pipe */
+    si_close (2); si_dup2 (out_fd[1],2);  /* set the stderr to the out pipe */
 
     execvp (args[0], args);      /* exec gdb */
@@ -520,7 +518,7 @@
   FD_SET (out_fd[0], &fdset);
 
-  write (in_fd[1], "backtrace\n", 10);
-  write (in_fd[1], "p si_stop_stack_trace_x = 0\n", 28);
-  write (in_fd[1], "quit\n", 5);
+  si_write (in_fd[1], "backtrace\n", 10);
+  si_write (in_fd[1], "p si_stop_stack_trace_x = 0\n", 28);
+  si_write (in_fd[1], "quit\n", 5);
 
   index = 0;
@@ -533,5 +531,5 @@
     tv.tv_usec = 0;
 
-    sel = select (FD_SETSIZE, &readset, NULL, NULL, &tv);
+    sel = si_select (FD_SETSIZE, &readset, NULL, NULL, &tv);
     if (sel == -1)
       break;
@@ -539,5 +537,5 @@
     if ((sel > 0) && (FD_ISSET (out_fd[0], &readset)))
     {
-      if (read (out_fd[0], &c, 1))
+      if (si_read (out_fd[0], &c, 1))
       {
         switch (state)
@@ -570,8 +568,8 @@
   }
 
-  close (in_fd[0]);
-  close (in_fd[1]);
-  close (out_fd[0]);
-  close (out_fd[1]);
+  si_close (in_fd[0]);
+  si_close (in_fd[1]);
+  si_close (out_fd[0]);
+  si_close (out_fd[1]);
   m2_end(0);
 }
Index: Singular/fehelp.cc
===================================================================
--- Singular/fehelp.cc	(revision bc0d32def5d3461a77eed40c1e1a3d254811858a)
+++ Singular/fehelp.cc	(revision bdda8c2a271e7650c11462d22c70cd15d21d34f1)
@@ -23,4 +23,6 @@
 
 #include <findexec/omFindExec.h>
+
+#include <Singular/si_signals.h>
 
 #include "ipid.h"
@@ -510,5 +512,5 @@
         hentry->url[i] = '\0';
 
-        if (fscanf(fd, "%ld\n", &(hentry->chksum)) != 1)
+        if (si_fscanf(fd, "%ld\n", &(hentry->chksum)) != 1)
         {
           hentry->chksum = -1;
@@ -638,5 +640,5 @@
   if (fd == NULL) return 0;
   memset(index_key,0,MAX_HE_ENTRY_LENGTH);
-  while (fscanf(fd, "%[^\t]\t%*[^\n]\n", index_key) == 1)
+  while (si_fscanf(fd, "%[^\t]\t%*[^\n]\n", index_key) == 1)
   {
     if ((index_key[MAX_HE_ENTRY_LENGTH-1]!='\0'))
@@ -1220,5 +1222,5 @@
   {
     // char* dummy=fgets(buffer, BUF_LEN, index); /* */
-    (void)sscanf(buffer, "Node:%[^\177]\177%ld\n", Index, &offset);
+    (void)si_sscanf(buffer, "Node:%[^\177]\177%ld\n", Index, &offset);
     for(p=Index; *p; p++) *p = tolow(*p);/* */
     (void)strcat(Index, " ");
Index: Singular/fereadl.c
===================================================================
--- Singular/fereadl.c	(revision bc0d32def5d3461a77eed40c1e1a3d254811858a)
+++ Singular/fereadl.c	(revision bdda8c2a271e7650c11462d22c70cd15d21d34f1)
@@ -195,5 +195,5 @@
       #endif
       /* OB: why this ? HS: char t_buf[128] does not work with glibc2 systems */
-      char *t_buf=(char *)omAlloc(128); 
+      char *t_buf=(char *)omAlloc(128);
       /*char t_buf[128];*/
       char *temp;
@@ -325,10 +325,10 @@
     /* check for CSI */
     c='\0';
-    read (STDIN_FILENO, &c, 1);
+    while((-1 == read (STDIN_FILENO, &c, 1)) && (errno == EINTR));
     if (c == '[')
     {
       /* get command character */
       c='\0';
-      read (STDIN_FILENO, &c, 1);
+      while((-1 == read (STDIN_FILENO, &c, 1)) && (errno == EINTR));
       switch (c)
       {
@@ -415,9 +415,14 @@
           tv.tv_sec = 0;
           tv.tv_usec = 0;
-          #ifdef hpux
-            sel = select (STDIN_FILENO+1, (int *)fdset.fds_bits, NULL, NULL, &tv);
-          #else
-            sel = select (STDIN_FILENO+1, &fdset, NULL, NULL, &tv);
-          #endif
+          do
+          {
+            sel = select (STDIN_FILENO+1,
+#ifdef hpux
+                          (int *)fdset.fds_bits,
+#else
+                          &fdset,
+#endif
+                          NULL, NULL, &tv);
+          } while( (sel == -1) && (errno == EINTR) );
           if (sel==0)
             fe_temp_reset();
@@ -770,5 +775,5 @@
     if (fe_rl_hdl==NULL) { return 1;}
 
-    fe_filename_completion_function= 
+    fe_filename_completion_function=
       dynl_sym(fe_rl_hdl, "filename_completion_function");
     if (fe_filename_completion_function==NULL) { res=3; break; }
@@ -825,5 +830,5 @@
 extern int history_total_bytes();
 extern int write_history (const char *);
-#endif    
+#endif
 void fe_reset_input_mode ()
 {
Index: Singular/links/semaphore.c
===================================================================
--- Singular/links/semaphore.c	(revision bc0d32def5d3461a77eed40c1e1a3d254811858a)
+++ Singular/links/semaphore.c	(revision bdda8c2a271e7650c11462d22c70cd15d21d34f1)
@@ -7,4 +7,5 @@
 
 #include <kernel/mod2.h>
+#include <Singular/si_signals.h>
 
 #ifdef HAVE_SIMPLEIPC
@@ -66,5 +67,5 @@
 {
   if ((id<0) || (id >= SIPC_MAX_SEMAPHORES) || (semaphore[id]==NULL))  return -1;
-  sem_wait(semaphore[id]);
+  si_sem_wait(semaphore[id]);
   return 1;
 }
@@ -73,5 +74,5 @@
 {
   if ((id<0) || (id >= SIPC_MAX_SEMAPHORES) || (semaphore[id]==NULL))  return -1;
-  return !sem_trywait(semaphore[id]);
+  return !si_sem_trywait(semaphore[id]);
 }
 
Index: Singular/links/silink.cc
===================================================================
--- Singular/links/silink.cc	(revision bc0d32def5d3461a77eed40c1e1a3d254811858a)
+++ Singular/links/silink.cc	(revision bdda8c2a271e7650c11462d22c70cd15d21d34f1)
@@ -31,4 +31,5 @@
 #include <Singular/links/ssiLink.h>
 #include <Singular/links/pipeLink.h>
+#include <Singular/si_signals.h>
 #include "feOpt.h"
 
@@ -159,5 +160,5 @@
   {
     struct stat buf;
-    if (lstat(l->name,&buf)==0) return "yes";
+    if (si_lstat(l->name,&buf)==0) return "yes";
     else return "no";
   }
Index: Singular/links/ssiLink.cc
===================================================================
--- Singular/links/ssiLink.cc	(revision bc0d32def5d3461a77eed40c1e1a3d254811858a)
+++ Singular/links/ssiLink.cc	(revision bdda8c2a271e7650c11462d22c70cd15d21d34f1)
@@ -199,9 +199,9 @@
       {
         mpz_t tmp;
-	mpz_init_set_si(tmp,nn);
+        mpz_init_set_si(tmp,nn);
         fputs("8 ",d->f_write);
         mpz_out_str (d->f_write,32, tmp);
         fputc(' ',d->f_write);
-	mpz_clear(tmp);
+        mpz_clear(tmp);
       }
       #endif
@@ -491,6 +491,6 @@
          mpz_init(((number_dummy)n)->z);
          mpz_init(((number_dummy)n)->n);
-	 s_readmpz_base (d->f_read,((number_dummy)n)->z, 32);
-	 s_readmpz_base (d->f_read,((number_dummy)n)->n, 32);
+         s_readmpz_base (d->f_read,((number_dummy)n)->z, 32);
+         s_readmpz_base (d->f_read,((number_dummy)n)->n, 32);
          ((number_dummy)n)->s=sub_type-5;
          return n;
@@ -500,5 +500,5 @@
          number n=(number)omAlloc0(sizeof(snumber_dummy));
          mpz_init(((number_dummy)n)->z);
-	 s_readmpz_base (d->f_read,((number_dummy)n)->z, 32);
+         s_readmpz_base (d->f_read,((number_dummy)n)->z, 32);
          ((number_dummy)n)->s=sub_type=3; /*subtype-5*/
          return n;
@@ -982,5 +982,5 @@
         char* cli_host = (char*)omAlloc(256);
         char* path = (char*)omAlloc(1024);
-        int r = sscanf(l->name,"%255[^:]:%s",cli_host,path);
+        int r = si_sscanf(l->name,"%255[^:]:%s",cli_host,path);
         if(r == 0)
         {
@@ -1039,5 +1039,5 @@
         struct hostent *server;
 
-        sscanf(l->name,"%255[^:]:%d",host,&portno);
+        si_sscanf(l->name,"%255[^:]:%d",host,&portno);
         //Print("connect to host %s, port %d\n",host,portno);mflush();
         if (portno!=0)
@@ -1301,5 +1301,5 @@
     case 19: res->rtyp=BIGINTMAT_CMD;
              res->data=ssiReadBigintmat(d);
-	     break;
+             break;
     case 20: ssiReadBlackbox(res,l);
              break;
Index: Singular/misc_ip.cc
===================================================================
--- Singular/misc_ip.cc	(revision bc0d32def5d3461a77eed40c1e1a3d254811858a)
+++ Singular/misc_ip.cc	(revision bdda8c2a271e7650c11462d22c70cd15d21d34f1)
@@ -15,4 +15,5 @@
 #include "config.h"
 #include <kernel/mod2.h>
+#include <Singular/si_signals.h>
 
 #ifdef HAVE_FACTORY
@@ -1027,5 +1028,5 @@
 int singular_fstat(int fd, struct stat *buf)
 {
-  return fstat(fd,buf);
+  return si_fstat(fd,buf);
 }
 
Index: findexec/feFopen.cc
===================================================================
--- findexec/feFopen.cc	(revision bc0d32def5d3461a77eed40c1e1a3d254811858a)
+++ findexec/feFopen.cc	(revision bdda8c2a271e7650c11462d22c70cd15d21d34f1)
@@ -5,4 +5,5 @@
 #include <sys/stat.h>
 #include <unistd.h>
+#include <errno.h>
 
 #include "config.h"
@@ -97,5 +98,10 @@
   {
     struct stat statbuf;
-    if ((stat(path,&statbuf)==0)
+    int res = -1;
+    do
+    {
+      res = stat(path,&statbuf);
+    } while((res < 0) and (errno == EINTR));
+    if ((res == 0)
     && (S_ISREG(statbuf.st_mode)))
       f = myfopen(path,mode);
Index: libpolys/coeffs/ffields.cc
===================================================================
--- libpolys/coeffs/ffields.cc	(revision bc0d32def5d3461a77eed40c1e1a3d254811858a)
+++ libpolys/coeffs/ffields.cc	(revision bdda8c2a271e7650c11462d22c70cd15d21d34f1)
@@ -22,4 +22,5 @@
 #include <string.h>
 #include <math.h>
+#include <errno.h>
 
 BOOLEAN nfGreaterZero (number k, const coeffs r);
@@ -225,5 +226,5 @@
 {
   assume(i==1);
-  
+
   if( i == 1 )
     return (number)1;
@@ -655,8 +656,8 @@
     /*this field is already set*/  return;
   int i=0;
-  
-  while ((fftable[i]!=c) && (fftable[i]!=0)) 
+
+  while ((fftable[i]!=c) && (fftable[i]!=0))
     i++;
-  
+
   if (fftable[i]==0)
   {
@@ -693,5 +694,11 @@
     }
     int q;
-    sscanf(buf,"%d %d",&r->m_nfCharP,&q);
+    int res = -1;
+    do
+    {
+      res = sscanf(buf,"%d %d",&r->m_nfCharP,&q);
+    }
+    while((res < 0) and (errno == EINTR));
+
     nfReadMipo(buf);
     r->m_nfCharQ1=r->m_nfCharQ-1;
@@ -829,10 +836,10 @@
 
   const int P = n_NumberOfParameters(r);
-  
+
   for( int i = 1; i <= P; i++ )
-    if (p[i-1] != NULL) 
+    if (p[i-1] != NULL)
       omFree( (ADDRESS)p[i-1] );
-  
-  omFreeSize((ADDRESS)p, P * sizeof(char*));  
+
+  omFreeSize((ADDRESS)p, P * sizeof(char*));
 }
 
@@ -865,5 +872,5 @@
   //r->cfRePart = ndCopy;
   //r->cfImPart = ndReturn0;
-  
+
   r->cfWriteLong = nfWriteLong;
   r->cfInit_bigint = nlModP;
@@ -884,5 +891,5 @@
   // debug stuff
   r->cfCoeffWrite=nfCoeffWrite;
-   
+
   r->cfParDeg = nfParDeg;
 
@@ -890,5 +897,5 @@
   r->cfDBTest=nfDBTest;
 #endif
-  
+
   // the variables:
   r->nNULL = (number)0;
@@ -900,5 +907,5 @@
 
   const char * name = p->GFPar_name;
-  
+
   r->m_nfCharQ = 0;
   r->m_nfCharP = p->GFChar;
@@ -913,5 +920,5 @@
   assume( pParameterNames != NULL );
   assume( pParameterNames[0] != NULL );
-  
+
   r->pParameterNames = pParameterNames;
   // NOTE: r->m_nfParameter was replaced by n_ParameterNames(r)[0]
@@ -937,5 +944,5 @@
   }
 
-  const double check= log ((double) (p->GFChar)); 
+  const double check= log ((double) (p->GFChar));
 
   if( (p->GFDegree * check) > sixteenlog2 )
@@ -950,5 +957,5 @@
 
   nfReadTable(c, r);
-  
+
   if( r->m_nfPlus1Table == NULL )
   {
@@ -958,13 +965,13 @@
     return TRUE;
   }
-  
-  
+
+
   assume (r -> m_nfCharQ > 0);
 
-  r->ch = r->m_nfCharP; 
+  r->ch = r->m_nfCharP;
   assume( r->m_nfPlus1Table != NULL );
-  
+
   return FALSE;
-  
+
 }
 
@@ -981,5 +988,5 @@
     char *s=StringEndS(); PrintS(s); omFree(s);
   }
-  else PrintS("//   minpoly        : ...\n"); 
+  else PrintS("//   minpoly        : ...\n");
 }
 
Index: libpolys/polys/mod_raw.cc
===================================================================
--- libpolys/polys/mod_raw.cc	(revision bc0d32def5d3461a77eed40c1e1a3d254811858a)
+++ libpolys/polys/mod_raw.cc	(revision bdda8c2a271e7650c11462d22c70cd15d21d34f1)
@@ -16,4 +16,5 @@
 #include <ctype.h>
 #include <sys/stat.h>
+#include <errno.h>
 
 
@@ -39,5 +40,5 @@
 char* si_bultin_libs[]={ SI_FOREACH_BUILTIN(SI_BUILTIN_LIBSTR)  NULL };
 
-#undef SI_BUILTIN_LIBSTR 
+#undef SI_BUILTIN_LIBSTR
 
 lib_types type_of_LIB(char *newlib, char *libnamebuf)
@@ -45,8 +46,8 @@
   const unsigned char mach_o[]={0xfe,0xed,0xfa,0xce,0};
   const unsigned char mach_O[]={0xce,0xfa,0xed,0xfe,0};
-   
+
   const unsigned char mach_o64[]={0xfe,0xed,0xfa,0xcf,0};
   const unsigned char mach_O64[]={0xcf,0xfa,0xed,0xfe,0};
-   
+
   int i=0;
   while(si_bultin_libs[i]!=NULL)
@@ -62,9 +63,13 @@
   struct stat sb;
   int nbytes = 0;
-  // int ret;
+  int ret;
   lib_types LT=LT_NONE;
 
   FILE * fp = feFopen( newlib, "r", libnamebuf, FALSE );
-  /*ret =*/ (void) stat(libnamebuf, &sb);
+
+  do
+  {
+    ret = stat(libnamebuf, &sb);
+  } while((ret < 0) and (errno == EINTR));
 
   if (fp==NULL)
