home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / unix / programm / 5382 < prev    next >
Encoding:
Text File  |  1992-11-20  |  1.2 KB  |  36 lines

  1. Newsgroups: comp.unix.programmer
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!darwin.sura.net!jvnc.net!nuscc!nusunix3.nus.sg!isc40038
  3. From: isc40038@nusunix1.nus.sg (LIM FANG HOW)
  4. Subject: How to extract file descriptor
  5. Message-ID: <1992Nov21.063524.16930@nuscc.nus.sg>
  6. Sender: usenet@nuscc.nus.sg
  7. Organization: National University of Singapore
  8. X-Newsreader: TIN [version 1.1 PL6]
  9. Date: Sat, 21 Nov 1992 06:35:24 GMT
  10. Lines: 24
  11.  
  12. I am trying to lock a file which is open using fopen. As what I know,
  13. fopen returns a file pointer which points to a structure that contains
  14. information about the file.But the flock function only takes a file
  15. descriptor and not a file pointer.
  16.  
  17. Qn1 : Does the structure pointed by file pointer contains the file
  18.       descriptor ? I could not find the file descriptor in the stdio.h
  19.       in my system (SUN sparc using 4.3BSD)
  20.  
  21. Qn2 : If yes, how to extract it from the structure ?
  22.       I tried the following and it returns fd not defined :
  23.               
  24.                FILE *fp;
  25.                    :
  26.                    :
  27.                fp=fopen("A","r");
  28.                    :
  29.                    :
  30.                fdes=fp->fd;
  31.  
  32. Qn3 : Is there any way to lock a file using the file pointer instead of
  33.       file descriptor ?
  34.  
  35.  
  36.