home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.programmer
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!darwin.sura.net!jvnc.net!nuscc!nusunix3.nus.sg!isc40038
- From: isc40038@nusunix1.nus.sg (LIM FANG HOW)
- Subject: How to extract file descriptor
- Message-ID: <1992Nov21.063524.16930@nuscc.nus.sg>
- Sender: usenet@nuscc.nus.sg
- Organization: National University of Singapore
- X-Newsreader: TIN [version 1.1 PL6]
- Date: Sat, 21 Nov 1992 06:35:24 GMT
- Lines: 24
-
- I am trying to lock a file which is open using fopen. As what I know,
- fopen returns a file pointer which points to a structure that contains
- information about the file.But the flock function only takes a file
- descriptor and not a file pointer.
-
- Qn1 : Does the structure pointed by file pointer contains the file
- descriptor ? I could not find the file descriptor in the stdio.h
- in my system (SUN sparc using 4.3BSD)
-
- Qn2 : If yes, how to extract it from the structure ?
- I tried the following and it returns fd not defined :
-
- FILE *fp;
- :
- :
- fp=fopen("A","r");
- :
- :
- fdes=fp->fd;
-
- Qn3 : Is there any way to lock a file using the file pointer instead of
- file descriptor ?
-
-
-