caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Xavier Leroy <Xavier.Leroy@inria.fr>
To: Ian T Zimmerman <itz@transbay.net>, caml-list@inria.fr
Subject: Re: Catching Break?
Date: Wed, 10 Feb 1999 16:48:45 +0100	[thread overview]
Message-ID: <19990210164845.08483@pauillac.inria.fr> (raw)
In-Reply-To: <m2socg2h5v.fsf@kronstadt.transbay.net>; from Ian T Zimmerman on Mon, Feb 08, 1999 at 11:02:52PM -0800

I'm glad you've figured out the problem, because I couldn't see it
from your sources...

In your example, it's indeed hard to guess which of the exceptions
Unix_error(EINTR) and Sys.Break will be raised.  Unix_error is raised
when the system call returns an "interrupted" error code, while
Sys.Break is raised when the handler associated with the signal is
executed.  Depending on the system call in question and on whether it
is restartable or not in case of signal, either of the two exceptions
can be raised first.  Moreover, if Unix_error occurs first and is
caught, Sys.Break can still occur at the next safe point, so it's
certainly very confusing.

If you're certain that all the system calls used are not restartable
(i.e. return EINTR immediately when interrupted by a signal),
a perhaps cleaner solution is to register an empty handler for SIGINT:

        Sys.handle Sys.sigint (fun _ -> ())

However, this is not portable (different Unixes have different restart
behaviors).

Perhaps pending signals should also be tested when an exception is
raised.  I'll have to think about this.

All the best,

- Xavier Leroy




  reply	other threads:[~1999-02-10 16:01 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
1999-02-09  7:02           ` Ian T Zimmerman
1999-02-10 15:48             ` Xavier Leroy [this message]
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=19990210164845.08483@pauillac.inria.fr \
    --to=xavier.leroy@inria.fr \
    --cc=caml-list@inria.fr \
    --cc=itz@transbay.net \
    /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).