home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / apps / database / ingres04.lzh / source / libq / IIexit.c < prev    next >
Encoding:
C/C++ Source or Header  |  1985-01-23  |  1.3 KB  |  73 lines

  1. # include    <ingres.h>
  2. # include    <symbol.h>
  3. # include    "IIglobals.h"
  4. # include    <sccs.h>
  5.  
  6. SCCSID(@(#)IIexit.c    8.1    12/31/84)
  7.  
  8.  
  9. /*
  10. **    Exit ingres --
  11. **        waits for the parser to return,
  12. **        catching all children's death till then
  13. **        or till an error return. 
  14. **        In case wait(II) is interrupted while waiting,
  15. **        as evidenced by errno == 4, waiting will resume.
  16. **
  17. */
  18.  
  19. IIexit()
  20. {
  21.     register int    ndx;
  22.     register int    pidptr;
  23.     register int    err;
  24.     int        status;
  25.     int        pidlist[10];
  26.     extern        errno;        /* perror(III) */
  27.  
  28. #    ifdef xETR1
  29.     if (IIdebug)
  30.         printf("IIexit\n");
  31. #    endif
  32.  
  33.     if (close(IIw_down) || close(IIr_down))
  34.         IIsyserr("IIexit:cant't close");
  35.  
  36.     pidptr = 0;
  37.     err = 0;
  38.     errno = 0;
  39.     while ((ndx = wait(&status)) != IIingpid
  40.         && (ndx != -1 || errno == 4))
  41.     {
  42.         if (ndx == -1)
  43.         {
  44.             errno = 0;
  45.             continue;
  46.         }
  47. #        ifdef xETR1
  48.         if (IIdebug)
  49.             printf("caught pid %u death, stat %d, %d\n",
  50.                 ndx, status >> 8, status & 0177);
  51. #        endif
  52.  
  53.         pidlist [pidptr++] = ndx;
  54.         if ((status & 0177) != 0)
  55.         {
  56.             printf("%d: Abnormal Termination %d", ndx, status & 0177);
  57.             if ((status & 0200) != 0)
  58.                 printf(" -- Core Dumped");
  59.             printf("\n");
  60.             err++;
  61.         }
  62.     }
  63.     if (err)
  64.     {
  65.         printf("pid list:");
  66.         for (ndx = 0; ndx < pidptr; ndx++)
  67.             printf(" %u", pidlist[ndx]);
  68.         printf("\n");
  69.     }
  70.  
  71.     IIingpid = 0;
  72. }
  73.