From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id LAA32364; Mon, 6 Sep 2004 11:07:44 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id LAA00949 for ; Mon, 6 Sep 2004 11:07:42 +0200 (MET DST) Received: from mta1.cl.cam.ac.uk (mta1.cl.cam.ac.uk [128.232.0.15]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id i8697gGX020306 for ; Mon, 6 Sep 2004 11:07:42 +0200 Received: from zonule.cl.cam.ac.uk ([128.232.9.23] helo=cl.cam.ac.uk ident=[zYqPtg7Ls/dmwIilqffYMOA7v2uK1EzO]) by mta1.cl.cam.ac.uk with esmtp (Exim 3.092 #1) id 1C4FTP-0006PY-00; Mon, 06 Sep 2004 10:07:39 +0100 X-Mailer: exmh version 2.6.3-CL 04/04/2003 with nmh-1.0.4 X-Exmh-Isig-CompType: repl X-Exmh-Isig-Folder: cslists/caml To: janne@hybrid.fi cc: caml-list@inria.fr Subject: Re: [Caml-list] Unix module and threads In-reply-to: Your message of "Sun, 05 Sep 2004 16:53:22 +0300." <413B1A52.8060007@hybrid.fi> Mime-Version: 1.0 Content-Type: text/plain Date: Mon, 06 Sep 2004 10:07:38 +0100 From: Keith Wansbrough Message-Id: X-Miltered: at concorde with ID 413C28DE.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 threads:01 threads:01 clarifying:01 work-around:01 portably:01 thread-safe:01 fork:01 fork:01 otherlibs:01 writes:01 unix:02 unix:02 module:03 markus:04 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Janne Hellsten writes: > Thank you Markus and David, this is sort of what I was afraid of (e.g., > curdir is shared among threads). Thank you for clarifying this. > > As my build scripts require the working directory to be set, I think I > have to work-around this and do something along the lines of: > > Unix.system "cd my_working_dir && build_cmd" > > I wonder if there's some other way of doing this portably and in a > thread-safe fashion? Instead of using Unix.system, do a fork()-and-exec() (as Unix.system presumably does under the hood), and set the current directory in the child process after the fork and before the exec. Take a look at the implementation of Unix.system in otherlibs/unix/unix.ml to see what I mean. --KW 8-) ------------------- 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