From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id KAA16419 for caml-red; Fri, 12 Jan 2001 10:08:48 +0100 (MET) 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 WAA06698 for ; Thu, 11 Jan 2001 22:34:39 +0100 (MET) Received: from julie.univ-savoie.fr (univax.univ-savoie.fr [193.48.120.32]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id f0BLYcj03094 for ; Thu, 11 Jan 2001 22:34:38 +0100 (MET) Received: from univ-savoie.fr (bppp1.univ-savoie.fr [193.48.120.20]) by julie.univ-savoie.fr (8.9.3/jtpda-5.3.3) with ESMTP id WAA47253 for ; Thu, 11 Jan 2001 22:34:36 +0100 (CET) Message-ID: <3A5E7A91.AC8FC7EF@univ-savoie.fr> Date: Thu, 11 Jan 2001 22:31:29 -0500 From: Christophe Raffalli Organization: Laboratoire de =?iso-8859-1?Q?Math=E9matiques?=, =?iso-8859-1?Q?Universit=E9?= de Savoie X-Mailer: Mozilla 4.76 [fr] (X11; U; Linux 2.2.17-21mdk i686) X-Accept-Language: fr, en MIME-Version: 1.0 To: caml-list@inria.fr Subject: restart any OCaml program from scratch: Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Sender: weis@pauillac.inria.fr I post the following lines taht may be useful to others: they provide a small command restart : unit -> unit which will restart your program from scratch. To use it just link you program with restart.cmo at first position. I have some questions for Unix and Windows specialist: - using "exit 3" is may be not the cleanest way ? - will this trick or a similar one work under windows ? - what should I do when the process status is WSIGNALED n (at the moment I do exit 1) ----- restart.mli ---------- val restart : unit -> 'a ----- restart.ml ---------- open Unix let restart () = exit 3 let _ = try while true do let pid = fork () in if pid = 0 then raise Exit else match waitpid [] pid with _, WEXITED 3 -> () | _, WEXITED n -> exit n | _, _ -> exit 1 done with Exit -> () -- Christophe Raffalli Université de Savoie Batiment Le Chablais, bureau 21 73376 Le Bourget-du-Lac Cedex tél: (33) 4 79 75 81 03 fax: (33) 4 79 75 87 42 mail: Christophe.Raffalli@univ-savoie.fr www: http://www.lama.univ-savoie.fr/~RAFFALLI