home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 300-399 / ff319.lzh / CNewsSrc / cnews.orig.lzh / libcnews / fopenclex.c < prev    next >
C/C++ Source or Header  |  1989-06-27  |  544b  |  30 lines

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