caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Richard W.M. Jones" <rich@annexia.org>
To: Khoo Yit Phang <khooyp@cs.umd.edu>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Race conditions with asynchronous exceptions in standard library
Date: Wed, 6 Jul 2011 22:13:12 +0100	[thread overview]
Message-ID: <20110706211312.GA17248@annexia.org> (raw)
In-Reply-To: <102E6342-F199-4A3C-B651-06795D14EB89@cs.umd.edu>


I don't find this surprising, and I don't think it's a problem with
OCaml or the standard library (or at least, it's not specific to OCaml).

Another solution to this which hasn't already been noted is to have
your signal write one byte on a pipe which "loops back" to the same
process, and then use a reactor / select / whatever in the main
program to catch this event.

http://cr.yp.to/docs/selfpipe.html

You might need to write such a signal handler in C to ensure it's
really safe.  In our experience, writing signal handlers correctly is
hard.  (Perhaps not as hard as all the scary stuff that happens with
threads, eg:
http://www.linuxprogrammingblog.com/threads-and-fork-think-twice-before-using-them )

Rich.

-- 
Richard Jones
Red Hat

  parent reply	other threads:[~2011-07-06 21:13 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-06  3:26 Khoo Yit Phang
2011-07-06  8:17 ` Mark Shinwell
2011-07-06  9:04   ` Fabrice Le Fessant
2011-07-06 18:06 ` Gerd Stolpmann
2011-07-06 21:13 ` Richard W.M. Jones [this message]
2011-07-06 23:40 ` [Caml-list] " Khoo Yit Phang
2011-07-07  0:07   ` Gerd Stolpmann
2011-07-09 13:02 ` [Caml-list] " ygrek

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=20110706211312.GA17248@annexia.org \
    --to=rich@annexia.org \
    --cc=caml-list@yquem.inria.fr \
    --cc=khooyp@cs.umd.edu \
    /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).