From: Ian T Zimmerman <itz@transbay.net>
To: Ian T Zimmerman <itz@transbay.net>
Cc: caml-list@inria.fr
Subject: Re: Catching Break?
Date: 06 Feb 1999 00:24:18 -0800 [thread overview]
Message-ID: <m2aeyslz2l.fsf@kronstadt.transbay.net> (raw)
In-Reply-To: Ian T Zimmerman's message of Thu, 28 Jan 1999 09:33:20 -0800
Ian T Zimmerman <itz@transbay.net> 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 <itz@transbay.net>
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_
next prev parent reply other threads:[~1999-02-08 8:03 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-01-25 18:43 Ian T Zimmerman
1999-01-26 0:24 ` Xavier Leroy
1999-01-26 6:46 ` Ian T Zimmerman
1999-01-28 11:14 ` Xavier Leroy
1999-01-28 17:33 ` Ian T Zimmerman
1999-02-06 8:24 ` Ian T Zimmerman [this message]
1999-02-09 7:02 ` Ian T Zimmerman
1999-02-10 15:48 ` Xavier Leroy
1999-02-05 18:00 ` Ian T Zimmerman
1999-02-08 17:16 ` Xavier Leroy
1999-01-26 5:17 Frank A. Christoph
1999-01-26 11:23 Toby Moth
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m2aeyslz2l.fsf@kronstadt.transbay.net \
--to=itz@transbay.net \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).