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
[Caml-list] Unix.file_descr -> int ???
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2002-06-11 (23:13)
From: Berke Durak <berke@a...>
Subject: Re: [Caml-list] Unix.file_descr -> int ???
On Wed, Jun 12, 2002 at 02:26:11AM +0700, Max Kirillov wrote:
> Hello.
> Anyway, any meaningful type barrier is good. Maybe the
> discussed too. But, since we all know that file_descr and
> dir_handle are integers, could it be worthwhile to have
> functions *_of_int and int_of_*?
> Max.


A file_descr_of_int function might seem meaningless at first, but with
inheritance of descriptors under Unix, some programs are intended to
be executed with a particular file descriptor configuration, eg. fd 3
is data stream, fd 4 is control, etc. OK, under Linux or BSD you can open
/proc/fd/xx or /fd/xx, but that's not really standard.

For the other direction, I'd suggest a "name_of_file_descr" function,
which, given a file descriptor, gives a platform-dependent string, for
debugging purposes. Under Unix, it could return the FD in decimal
format ; under other OSes, it could return a hexadecimal pointer
Berke Durak
To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: