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 RAA31102 for caml-redistribution; Wed, 10 Feb 1999 17:01:35 +0100 (MET) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id QAA02606 for ; Wed, 10 Feb 1999 16:49:05 +0100 (MET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.8.7/8.8.7) with ESMTP id QAA14676; Wed, 10 Feb 1999 16:48:45 +0100 (MET) Received: (from xleroy@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id QAA22772; Wed, 10 Feb 1999 16:48:45 +0100 (MET) Message-ID: <19990210164845.08483@pauillac.inria.fr> Date: Wed, 10 Feb 1999 16:48:45 +0100 From: Xavier Leroy To: Ian T Zimmerman , caml-list@inria.fr Subject: Re: Catching Break? References: <199901281733.JAA05913@kronstadt.transbay.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.89.1 In-Reply-To: ; from Ian T Zimmerman on Mon, Feb 08, 1999 at 11:02:52PM -0800 Sender: weis 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