From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p66LDMWi017453 for ; Wed, 6 Jul 2011 23:13:22 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av0EAMbOFE5QRFuw/2dsb2JhbABTEKd7d4h8wwWGNwSiRzg X-IronPort-AV: E=Sophos;i="4.65,489,1304287200"; d="scan'208";a="86724080" Received: from furbychan.cocan.org ([80.68.91.176]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/AES256-SHA; 06 Jul 2011 23:13:16 +0200 Received: from rich by furbychan.cocan.org with local (Exim 4.72) (envelope-from ) id 1QeZPE-0004az-S2; Wed, 06 Jul 2011 22:13:12 +0100 Date: Wed, 6 Jul 2011 22:13:12 +0100 From: "Richard W.M. Jones" To: Khoo Yit Phang Cc: caml-list@yquem.inria.fr Message-ID: <20110706211312.GA17248@annexia.org> References: <102E6342-F199-4A3C-B651-06795D14EB89@cs.umd.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <102E6342-F199-4A3C-B651-06795D14EB89@cs.umd.edu> User-Agent: Mutt/1.5.20 (2009-06-14) Subject: Re: [Caml-list] Race conditions with asynchronous exceptions in standard library 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