From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: weis Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id PAA29385 for caml-redistribution; Mon, 10 Mar 1997 15:32:59 +0100 (MET) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id PAA28675 for ; Mon, 10 Mar 1997 15:02:47 +0100 (MET) Received: from heaton.cl.cam.ac.uk (heaton.cl.cam.ac.uk [128.232.32.11]) by nez-perce.inria.fr (8.7.6/8.7.3) with SMTP id PAA09351 for ; Mon, 10 Mar 1997 15:02:42 +0100 (MET) Received: from cl.cam.ac.uk [128.232.33.49] (ptw20) by heaton.cl.cam.ac.uk with esmtp (Exim 1.59 #2) id 0w45eJ-0002gB-00; Mon, 10 Mar 1997 14:01:59 +0000 X-Mailer: exmh version 1.6.9+cl+PEM 96/8/21 To: caml-list@inria.fr cc: Pawel.Wojciechowski@cl.cam.ac.uk Subject: Conversion between file descriptors and strings Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Mon, 10 Mar 1997 14:01:57 +0000 From: Pawel Wojciechowski Message-Id: Sender: weis Hi all, I just started programming in the Objective Caml language. At the current stage of my project, I need to implement a communication between a process and its child process, which is created by 'fork'. I decided to use pipes from the Unix library. Instead of exchanging standard descriptors (0 and 1) for descriptors fd_in and fd_out created by 'pipe' (as in the expression (fd_out, fd_in) = pipe()), I'd prefer to pass descriptors fd_out and fd_in, to a program executed as a forked process, as arguments when invoking 'execvp'. Then, you can pass these values to the program (which is stored in a separate file and compiled separately) as an array of *strings* being a structural argument to the 'execvp'. My question is how to convert a descriptor of type file_descr into a string and vice-versa? In C, there is no such problems, since descriptors are integers, and you can always write accordingly: sprintf(arg1, "%d", pipe[0]) and descr = atoi(argv[1]) In strongly-typed (O)Caml, we should expect the following error message: "This expression has type int but is here used with type Unix.file_descr" I don't have much experience in using (O)Caml so appologize if you consider that my problem is trivial but please help me sort it out! :) regards, Pawel ps. Pipe is a function from the Unix library and it has types as follows: pipe : init -> file_descr * file_desc