home *** CD-ROM | disk | FTP | other *** search
/ Unix System Administration Handbook 1997 October / usah_oct97.iso / news / cnews.tar / libc / closeall.c < prev    next >
C/C++ Source or Header  |  1994-03-24  |  352b  |  20 lines

  1. #include <sys/types.h>
  2. #include <sys/param.h>
  3.  
  4. /* if NOFILE wasn't defined in sys/param.h, try for sysconf()... */
  5. #ifndef NOFILE
  6. #include <unistd.h>
  7. #define    NOFILE    ((int)sysconf(_SC_OPEN_MAX))
  8. #endif
  9.  
  10. void
  11. closeall(leavestd)
  12. int leavestd;
  13. {
  14.     register int i;
  15.     register int openmax = NOFILE;
  16.  
  17.     for (i = (leavestd? 3: 0); i < openmax; i++)
  18.         close(i);
  19. }
  20.