Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
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.

Hi

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
value.
--
Berke Durak
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners