home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / c / 16963 < prev    next >
Encoding:
Internet Message Format  |  1992-11-21  |  1.4 KB

  1. Path: sparky!uunet!think.com!barmar
  2. From: barmar@think.com (Barry Margolin)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: How to extract file descriptor
  5. Date: 21 Nov 1992 20:08:17 GMT
  6. Organization: Thinking Machines Corporation, Cambridge MA, USA
  7. Lines: 31
  8. Message-ID: <1em4vhINNsen@early-bird.think.com>
  9. References: <1992Nov21.065113.21296@nuscc.nus.sg>
  10. NNTP-Posting-Host: telecaster.think.com
  11.  
  12. In article <1992Nov21.065113.21296@nuscc.nus.sg> isc40038@nusunix1.nus.sg (LIM FANG HOW) writes:
  13. >Qn1 : Does the structure pointed by file pointer contains the file
  14. >      descriptor ? I could not find the file descriptor in the stdio.h
  15. >      in my system (SUN sparc using 4.3BSD)
  16.  
  17. It's called "_file" in the struct _iobuf.  But you don't really need to
  18. know that, since it's very system-specific.
  19.  
  20. >Qn2 : If yes, how to extract it from the structure ?
  21.  
  22. Use the fileno() macro, which takes a FILE*.  This should be portable
  23. across most Unix flavors, and maybe even to some non-Unix systems.
  24.  
  25. >      I tried the following and it returns fd not defined :
  26. ...
  27. >               fdes=fp->fd;
  28.  
  29. That should be
  30.  
  31.         fdes=fileno(fp);
  32.  
  33. >Qn3 : Is there any way to lock a file using the file pointer instead of
  34. >      file descriptor ?
  35.  
  36. No, locking is not part of stdio.  Many systems that can support stdio
  37. (i.e. just about any system) don't support file locking.
  38. -- 
  39. Barry Margolin
  40. System Manager, Thinking Machines Corp.
  41.  
  42. barmar@think.com          {uunet,harvard}!think!barmar
  43.