Index: Singular/iparith.cc
===================================================================
--- Singular/iparith.cc	(revision 2404eaa111daafc0bf19376132cb7a10c7f21daf)
+++ Singular/iparith.cc	(revision 1edbcdd9aacbc8f6df5cfcb2f919372f72e6e889)
@@ -3203,5 +3203,6 @@
 //           or 0 for polling
 // returns: ERROR (via Werror): timeout negative
-//           0: timeout (or polling): none ready
+//           -1: the read state of all links is eof
+//            0: timeout (or polling): none ready
 //           i>0: (at least) L[i] is ready
   lists Lforks = (lists)u->Data();
@@ -3212,4 +3213,8 @@
   }
   int i = slStatusSsiL(Lforks, t*1000);
+  if(i == -2) /* error */
+  {
+    return TRUE;
+  }
   res->data = (void*)(long)i;
   return FALSE;
@@ -3222,6 +3227,8 @@
 //           or 0 for polling
 // returns: ERROR (via Werror): timeout negative
+//           -1: the read state of all links is eof
 //           0: timeout (or polling): none ready
 //           1: all links are ready
+//              (caution: at least one is ready, but some maybe dead)
   lists Lforks = (lists)u->CopyD();
   int timeout = 1000*(int)(long)v->Data();
@@ -3232,10 +3239,11 @@
   int t = 1000*getRTimer()/TIMER_RESOLUTION;
   int i;
-  int ret = 1;
-  for(int nfinished = 0; nfinished < Lforks->nr; nfinished++)
+  int ret = -1;
+  for(int nfinished = 0; nfinished < Lforks->nr+1; nfinished++)
   {
     i = slStatusSsiL(Lforks, timeout);
-    if(i > 0)
-    {
+    if(i > 0) /* Lforks[i] is ready */
+    {
+      ret = 1;
       Lforks->m[i-1].CleanUp();
       Lforks->m[i-1].rtyp=DEF_CMD;
@@ -3243,5 +3251,16 @@
       timeout = si_max(0,timeout - 1000*getRTimer()/TIMER_RESOLUTION + t);
     }
-    else { ret = 0; break; /* terminate the for loop */ }
+    else /* terminate the for loop */
+    {
+      if(i == -2) /* error */
+      {
+        return TRUE;
+      }
+      if(i == 0) /* timeout */
+      {
+        ret = 0;
+      }
+      break;
+    }
   }
   Lforks->Clean();
@@ -4618,7 +4637,12 @@
 // input: u: a list with links of type
 //           ssi-fork, ssi-tcp, MPtcp-fork or MPtcp-launch
-// returns: i>0: (at least) a[i] is ready
+// returns: -1:  the read state of all links is eof
+//          i>0: (at least) u[i] is ready
   lists Lforks = (lists)u->Data();
   int i = slStatusSsiL(Lforks, -1);
+  if(i == -2) /* error */
+  {
+    return TRUE;
+  }
   res->data = (void*)(long)i;
   return FALSE;
@@ -4628,14 +4652,27 @@
 // input: u: a list with links of type
 //           ssi-fork, ssi-tcp, MPtcp-fork or MPtcp-launch
-// returns: nothing. All links are ready when finished.
+// returns: -1: the read state of all links is eof
+//           1: all links are ready
+//              (caution: at least one is ready, but some maybe dead)
   lists Lforks = (lists)u->CopyD();
   int i;
-  for(int nfinished = 0; nfinished < Lforks->nr; nfinished++)
+  int j = -1;
+  for(int nfinished = 0; nfinished < Lforks->nr+1; nfinished++)
   {
     i = slStatusSsiL(Lforks, -1);
+    if(i == -2) /* error */
+    {
+      return TRUE;
+    }
+    if(i == -1)
+    {
+      break;
+    }
+    j = 1;
     Lforks->m[i-1].CleanUp();
     Lforks->m[i-1].rtyp=DEF_CMD;
     Lforks->m[i-1].data=NULL;
   }
+  res->data = (void*)(long)j;
   Lforks->Clean();
   return FALSE;
Index: Singular/misc_ip.cc
===================================================================
--- Singular/misc_ip.cc	(revision 2404eaa111daafc0bf19376132cb7a10c7f21daf)
+++ Singular/misc_ip.cc	(revision 1edbcdd9aacbc8f6df5cfcb2f919372f72e6e889)
@@ -1059,5 +1059,8 @@
   else
   {
-      printf("\nhalt %d\n",i);
+      if(!singular_in_batchmode)
+      {
+        printf("\nhalt %d\n",i);
+      }
   }
   #ifdef HAVE_MPSR
Index: Singular/ssiLink.cc
===================================================================
--- Singular/ssiLink.cc	(revision 2404eaa111daafc0bf19376132cb7a10c7f21daf)
+++ Singular/ssiLink.cc	(revision 1edbcdd9aacbc8f6df5cfcb2f919372f72e6e889)
@@ -1197,5 +1197,6 @@
 {
 // input: L: a list with links of type
-//           ssi-fork, ssi-tcp, MPtcp-fork or MPtcp-launch
+//           ssi-fork, ssi-tcp, MPtcp-fork or MPtcp-launch.
+//           Note: Not every entry in L must be set.
 //        timeout: timeout for select in micro-seconds
 //           or -1 for infinity
@@ -1203,5 +1204,6 @@
 // returns: ERROR (via Werror): L has wrong elements or link not open
 //           -2: select returns an error
-//           0: timeout or (polling): none ready
+//           -1: the read state of all links is eof
+//           0:  timeout (or polling): none ready,
 //           i>0: (at least) L[i] is ready
   si_link l;
@@ -1212,8 +1214,43 @@
   int d_fd;
   fd_set  mask, fdmask;
+  FD_ZERO(&fdmask);
   FD_ZERO(&mask);
-  int max_fd=0; /* max fd in fd_set */
-  struct timeval wt;
+  int max_fd=0; /* 1 + max fd in fd_set */
+
+  /* timeout */
+  struct timespec wt;
+  int startingtime = getRTimer()/TIMER_RESOLUTION;  // in seconds
+  struct timespec *wt_ptr=&wt;
+  if (timeout== -1)
+  {
+    wt_ptr=NULL;
+  }
+  else
+  {
+    wt.tv_sec  = timeout / 1000000;
+    wt.tv_nsec = 1000 * (timeout % 1000000);
+  }
+
+  /* signal mask for pselect() */
+  sigset_t sigmask;
+  if(sigprocmask(SIG_SETMASK, NULL, &sigmask) < 0)
+  {
+    WerrorS("error in sigprocmask()");
+    return -2;
+  }
+  if(sigaddset(&sigmask, SIGCHLD) < 0)
+  {
+    WerrorS("error in sigaddset()");
+    return -2;
+  }
+
+  /* auxiliary variables */
   int i;
+  int j;
+  int k;
+  int s;
+  char fdmaskempty;
+
+  /* check the links and fill in fdmask */
   for(i=L->nr; i>=0; i--)
   {
@@ -1229,5 +1266,6 @@
         && (strcmp(l->mode,"launch")!=0)))
       {
-        WerrorS("all links must be of type ssi:fork, ssi:tcp, MPtcp:fork or MPtcp:launch");
+        WerrorS("all links must be of type ssi:fork, ssi:tcp, MPtcp:fork\n");
+        WerrorS("or MPtcp:launch");
         return -2;
       }
@@ -1247,21 +1285,24 @@
       d_fd=d->fd_read;
     #endif
-      FD_SET(d_fd, &mask);
+      FD_SET(d_fd, &fdmask);
       if (d_fd > max_fd) max_fd=d_fd;
     }
   }
   max_fd++;
-  struct timeval *wt_ptr=&wt;
-  if (timeout== -1)
-  {
-    wt_ptr=NULL;
-  }
-  else
-  {
-    wt.tv_sec  = timeout / 1000000;
-    wt.tv_usec = timeout % 1000000;
-  }
+
+do_select:
+  /* copy fdmask to mask */
+  FD_ZERO(&mask);
+  for(k = 0; k < max_fd; k++)
+  {
+    if(FD_ISSET(k, &fdmask))
+    {
+      FD_SET(k, &mask);
+    }
+  }
+
   /* check with select: chars waiting: no -> not ready */
-  int s= select(max_fd, &mask, NULL, NULL, wt_ptr);
+  s = pselect(max_fd, &mask, NULL, NULL, wt_ptr, &sigmask);
+Print("\nselect: %d\n", s);
   if (s==-1)
   { 
@@ -1269,17 +1310,7 @@
     return -2; /*error*/
   }
-  int j;
-  int retry_needed=0;
-find_next_fd:
   if (s==0)
   {
-    if (retry_needed)
-    {
-      // the os reported that one of the (ssi) links is ready,
-      // but it was only white space: this cannot happen again:
-      return slStatusSsiL(L,timeout);
-    }
-    else
-      return 0; /*poll: not ready */
+    return 0; /*poll: not ready */
   }
   else /* s>0, at least one ready  (the number of fd which are ready is s)*/
@@ -1322,11 +1353,30 @@
       int c=fgetc(d->f_read);
       //Print("try c=%d\n",c);
-      if (c== -1) /* eof or error*/
-      {
-        retry_needed=1;
-        FD_CLR(j,&mask);
-        s--;
-        goto find_next_fd;
-      }
+      if (c== -1) /* eof */
+      {
+        FD_CLR(j,&fdmask);
+        fdmaskempty = 1;
+        for(k = 0; k < max_fd; k++)
+        {
+          if(FD_ISSET(k, &fdmask))
+          {
+            fdmaskempty = 0;
+            break;
+          }
+        }
+        if(fdmaskempty)
+        {
+          return -1;
+        }
+        if(timeout != -1)
+        {
+          timeout = si_max(0,
+               timeout - 1000000*(getRTimer()/TIMER_RESOLUTION - startingtime));
+          wt.tv_sec  = timeout / 1000000;
+          wt.tv_nsec = 1000 * (timeout % 1000000);
+        }
+        goto do_select;
+      }
+
       else if (isdigit(c))
       { ungetc(c,d->f_read); d->ungetc_buf='\1'; return i+1; }
Index: Singular/table.h
===================================================================
--- Singular/table.h	(revision 2404eaa111daafc0bf19376132cb7a10c7f21daf)
+++ Singular/table.h	(revision 1edbcdd9aacbc8f6df5cfcb2f919372f72e6e889)
@@ -282,5 +282,5 @@
 ,{D(loNewtonP),    NEWTONPOLY_CMD,  IDEAL_CMD,      IDEAL_CMD     , ALLOW_PLURAL |ALLOW_RING}
 ,{D(jjWAIT1ST1),   WAIT1ST_CMD,     INT_CMD,        LIST_CMD      , ALLOW_PLURAL |ALLOW_RING}
-,{D(jjWAITALL1),   WAITALL_CMD,     NONE,           LIST_CMD      , ALLOW_PLURAL |ALLOW_RING}
+,{D(jjWAITALL1),   WAITALL_CMD,     INT_CMD,        LIST_CMD      , ALLOW_PLURAL |ALLOW_RING}
 ,{NULL,             0,               0,              0             , NO_PLURAL |NO_RING}
 };
