Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Re : [Caml-list] file_desc
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2008-07-01 (14:56)
From: Matthieu Wipliez <mwipliez@y...>
Subject: Re : [Caml-list] file_desc
----- Message d'origine ----
> De : Robert Fischer <>
> À : caml-list <>
> Envoyé le : Mardi, 1 Juillet 2008, 16h35mn 53s
> Objet : [Caml-list] file_desc
> Is there a way to convert a file_descr to/from an int in OCaml?  The type is 
> abstract, and there
> doesn't seem to be an obvious answer.

It is defined in the Unix module as an int. Perhaps some Obj.magic can do the trick?

For Windows however things are more complicated, because a file_descr is a "struct filedescr" value. It is possible to obtain an int from this using the win_CRT_fd_of_filedescr function or the CRT_fd_val(v) macro, both defined in unixsupport.h.
I think you can either use Obj.field or write a C function (basically calling win_CRT_fd_of_filedescr) to access this information.

> Alternatively, is there a way to get at an inherited file_descr from a process I 
> execv'd into?

However I don't know about that :D

> ~~ Robert.


> _______________________________________________
> Caml-list mailing list. Subscription management:
> Archives:
> Beginner's list:
> Bug reports:

Envoyez avec Yahoo! Mail. Une boite mail plus intelligente