[Gllug] Off Topic: C File Descriptors

Vidar Hokstad vidar at aardvarkmedia.co.uk
Fri Mar 7 09:44:43 UTC 2008


On 7 Mar 2008, at 01:41, salsaman at xs4all.nl wrote:
>
> something like this (untested, YMMV) should do it:

I think the suggestion of fstat() is better (two filenames under /dev  
can easily point to the same device nodes, for example), and fstat()  
is also more portable (should be there on any POSIX compliant system),  
but if you're first going to dig into /proc:

> int mypid=(int)getpid();
> sprintf(string,"/proc/%d/fd/1",mypid);

... this isn't needed - "/proc/self" refers the current process, so  
you can just use "/proc/self/fd/1" and "/proc/self/fd/2".

Vidar

-- 
Vidar Hokstad
Technical Director
Aardvark Media Limited

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.lug.org.uk/pipermail/gllug/attachments/20080307/d9fd093b/attachment.html>
-------------- next part --------------
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug


More information about the GLLUG mailing list