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 JAA22302 for caml-redistribution; Mon, 8 Feb 1999 09:03:18 +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 JAA17017 for ; Sat, 6 Feb 1999 09:57:17 +0100 (MET) Received: from kronstadt.transbay.net (ip55247.transbay.net [209.133.55.247]) by nez-perce.inria.fr (8.8.7/8.8.7) with ESMTP id JAA12135 for ; Sat, 6 Feb 1999 09:57:13 +0100 (MET) Received: (from itz@localhost) by kronstadt.transbay.net (8.8.6/8.8.6) id AAA31879; Sat, 6 Feb 1999 00:24:19 -0800 Sender: weis To: Ian T Zimmerman Cc: caml-list@inria.fr Subject: Re: Catching Break? References: <199901281733.JAA05913@kronstadt.transbay.net> From: Ian T Zimmerman Date: 06 Feb 1999 00:24:18 -0800 In-Reply-To: Ian T Zimmerman's message of Thu, 28 Jan 1999 09:33:20 -0800 Message-ID: X-Mailer: Gnus v5.3/Emacs 19.34 Ian T Zimmerman writes: > Ok, I see that I'll have to start posting my real code, because I > still can't make it work despite (imperfect) analogy with the > example. > let remove_pair prefix pid = > let spid = string_of_int pid in let iname = prefix ^ spid ^ ".i" > and oname = prefix ^ spid ^ ".o" in Sys.remove iname; Sys.remove > oname > let open_pair prefix pid respond = > let spid = string_of_int pid in let iname = prefix ^ spid ^ ".i" > and oname = prefix ^ spid ^ ".o" and iflags = [Unix.O_RDONLY ; > Unix.O_NONBLOCK] and oflags = [Unix.O_WRONLY] in let id x = x in > Sys.catch_break true; let (ind, outd) = try if respond then > let outd = Unix.openfile iname oflags 0 in let ind = > Unix.openfile oname iflags 0 in id (ind, outd) > else > let ind = Unix.openfile iname iflags 0 in let outd = > Unix.openfile oname oflags 0 in (* HERE! *) id (ind, outd) > with Sys.Break -> > if not respond then remove_pair prefix pid; Sys.catch_break > false; exit 0; assert false in > Sys.catch_break false; (ind, outd) > > The files referred to by [io]name are named pipes; the write open > hangs until the other side is opened, which may never happen. So as > to have a chance to clean up (namely remove the pipes), I must allow > _and_ catch Control-C as I'm trying to. But it doesn't work; if I > hit Control-C while blocked in the open marked, I never get into the > with handler. > I tried this: let remove_pair prefix pid = let spid = string_of_int pid in let iname = prefix ^ spid ^ ".i" and oname = prefix ^ spid ^ ".o" in Sys.remove iname; Sys.remove oname let open_pair prefix pid respond = let spid = string_of_int pid in let iname = prefix ^ spid ^ ".i" and oname = prefix ^ spid ^ ".o" and iflags = [Unix.O_RDONLY ; Unix.O_NONBLOCK] and oflags = [Unix.O_WRONLY] in Sys.catch_break true; let (ind, outd) = try if respond then let outd = Unix.openfile iname oflags 0 in let ind = Unix.openfile oname iflags 0 in for i = 0 to 1 do () done; (ind, outd) else let ind = Unix.openfile iname iflags 0 in let outd = Unix.openfile oname oflags 0 in for i = 0 to 1 do () done; (ind, outd) with Sys.Break -> if not respond then remove_pair prefix pid; Sys.catch_break false; exit 0; assert false in Sys.catch_break false; (ind, outd) ... and it doesn't work, either :-( I am really stumped, please help. -- Ian T Zimmerman I came to the conclusion that what was wrong about the guillotine was that the condemned man had no chance at all, absolutely none. Albert Camus, _The Outsider_