home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 400-499 / ff473.lzh / CNewsSrc / cnews_src.lzh / libcnews / fopenclex.c < prev    next >
C/C++ Source or Header  |  1990-05-29  |  575b  |  32 lines

  1. /*
  2.  * fopen and set close-on-exec (to avoid leaking descriptors into children)
  3.  */
  4.  
  5. #include <stdio.h>
  6. #ifdef unix
  7. # include <sys/types.h>
  8. #endif /* unix */
  9. #include "news.h"
  10.  
  11. FILE *
  12. fopenwclex(name, mode)    /* open name; close-on-exec if OK, else warning */
  13. char *name, *mode;
  14. {
  15.     register FILE *fp;
  16.  
  17.     if ((fp = fopenclex(name, mode)) == NULL)
  18.         warning("can't open `%s'", name);
  19.     return fp;
  20. }
  21.  
  22. FILE *
  23. fopenclex(file, mode)        /* open file and if OK, close-on-exec */
  24. char *file, *mode;
  25. {
  26.     register FILE *fp;
  27.  
  28.     if ((fp = fopen(file, mode)) != NULL)
  29.         fclsexec(fp);
  30.     return fp;
  31. }
  32.