home *** CD-ROM | disk | FTP | other *** search
/ Unix System Administration Handbook 1997 October / usah_oct97.iso / news / cnews.tar / libfake / fcntl.c < prev    next >
C/C++ Source or Header  |  1993-11-20  |  615b  |  25 lines

  1. #include <stdio.h>
  2. #include <sys/types.h>
  3. #include <sgtty.h>
  4. #include <fcntl.h>
  5.  
  6. /*
  7.  * fake fcntl(), just smart enough to do set-close-on-exec
  8.  *
  9.  * Advanced cleverness here...  Our <fcntl.h> defines fcntl to cnewsfcntl.
  10.  * If you use our <fcntl.h> but not our fcntl.c, the linker will barf.  If
  11.  * you use the system <fcntl.h>, presumably indicating that you have a
  12.  * real fcntl(), it will get called, not this.
  13.  */
  14. void
  15. cnewsfcntl(fd, code, value)
  16. int fd;
  17. int code;
  18. int value;
  19. {
  20.     if (code == F_SETFD && value == 1)
  21.         (void) ioctl(fd, FIOCLEX, (char *)NULL);
  22.     else
  23.         error("invalid call to faked fcntl()", "");
  24. }
  25.