home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!cs.utexas.edu!sun-barr!ames!pacbell.com!iggy.GW.Vitalink.COM!cs.widener.edu!dsinc!ub!acsu.buffalo.edu!raman-v
- From: raman-v@cs.Buffalo.EDU (Vemulapati V. Ramanaprasad)
- Newsgroups: comp.unix.programmer
- Subject: Re: How to extract file descriptor
- Message-ID: <By2z0z.8pp@acsu.buffalo.edu>
- Date: 21 Nov 92 19:19:46 GMT
- References: <1992Nov21.063524.16930@nuscc.nus.sg>
- Sender: nntp@acsu.buffalo.edu
- Organization: State University of New York at Buffalo / CEDAR Research Group
- Lines: 28
- Originator: raman-v@arneb.cs.buffalo.edu
- Nntp-Posting-Host: arneb.cs.buffalo.edu
-
-
- In article <1992Nov21.063524.16930@nuscc.nus.sg>, isc40038@nusunix1.nus.sg (LIM FANG HOW) writes:
- |> 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 ?
- |>
- |>
-
- You can use the function fileno() which takes a file pointer as an argument and returns the file descriptor. See the man page for details.
-