File * to fd
From: Kamal R. Prasad (kamalp_at_acm.org)
Date: 12/23/04
- Previous message: Kamal R. Prasad: "Role of process priority in locking mechanism"
- Next in thread: Jens.Toerring_at_physik.fu-berlin.de: "Re: File * to fd"
- Reply: Jens.Toerring_at_physik.fu-berlin.de: "Re: File * to fd"
- Reply: Rich Gibbs: "Re: File * to fd"
- Reply: Casper H.S. ***: "Re: File * to fd"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 23 Dec 2004 10:10:43 -0800
From: termbios (meson@techemail.com)
Subject: File * to fd
View this article only
Newsgroups: comp.unix.programmer
Date: 2004-12-22 15:24:08 PST
>I get a FILE * pointer by calling popen. Now I want to change it into
a
>file descriptor. Is there a function call for it? Like fdopen create
a
>FILE* out of a file descriptor.
FILE (struct __sFILE) has a member
short _file; /* fileno, if Unix descriptor, else -1 */
so, you just need to access (assuming your FILE* is fp) fp->_file to
access the related file descriptor. Im not aware if the member varies
across implementations -but if it doesn't, you save yourself a
function call by accessing the member directly.
regards
-kamal
- Previous message: Kamal R. Prasad: "Role of process priority in locking mechanism"
- Next in thread: Jens.Toerring_at_physik.fu-berlin.de: "Re: File * to fd"
- Reply: Jens.Toerring_at_physik.fu-berlin.de: "Re: File * to fd"
- Reply: Rich Gibbs: "Re: File * to fd"
- Reply: Casper H.S. ***: "Re: File * to fd"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]