From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 433A67EE80; Fri, 15 Mar 2013 16:11:36 +0100 (CET) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of oliver@first.in-berlin.de) identity=pra; client-ip=192.109.42.8; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="oliver@first.in-berlin.de"; x-sender="oliver@first.in-berlin.de"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of oliver@first.in-berlin.de) identity=mailfrom; client-ip=192.109.42.8; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="oliver@first.in-berlin.de"; x-sender="oliver@first.in-berlin.de"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@einhorn.in-berlin.de) identity=helo; client-ip=192.109.42.8; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="oliver@first.in-berlin.de"; x-sender="postmaster@einhorn.in-berlin.de"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AsEIAEQ5Q1HAbSoIiWdsb2JhbABDiDG3RoUbAwGBZRYOAQEBFRIUBCSCKgEBBSMEUhALCQUKAgIFIQICDwUYMROIFASwHZJ2FYEOjRVdB4ItMmEDjkSIFoEgkm4 X-IPAS-Result: AsEIAEQ5Q1HAbSoIiWdsb2JhbABDiDG3RoUbAwGBZRYOAQEBFRIUBCSCKgEBBSMEUhALCQUKAgIFIQICDwUYMROIFASwHZJ2FYEOjRVdB4ItMmEDjkSIFoEgkm4 X-IronPort-AV: E=Sophos;i="4.84,850,1355094000"; d="scan'208";a="6643276" Received: from einhorn.in-berlin.de ([192.109.42.8]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 15 Mar 2013 16:11:35 +0100 X-Envelope-From: oliver@first.in-berlin.de Received: from first (e178037077.adsl.alicedsl.de [85.178.37.77]) (authenticated bits=0) by einhorn.in-berlin.de (8.13.6/8.13.6/Debian-1) with ESMTP id r2FFBYuR019828 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Fri, 15 Mar 2013 16:11:34 +0100 Received: by first (Postfix, from userid 1000) id 595D715400E6; Fri, 15 Mar 2013 16:11:33 +0100 (CET) Date: Fri, 15 Mar 2013 16:11:34 +0100 From: oliver To: Jeremie Dimino Cc: caml-list@inria.fr, ocsigen@inria.fr Message-ID: <20130315151134.GA5194@siouxsie> References: <5142E780.7060806@hars.de> <20130315124345.GB3262@siouxsie> <20130315141735.GA4697@siouxsie> <20130315142715.GC4697@siouxsie> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) X-Scanned-By: MIMEDefang_at_IN-Berlin_e.V. on 192.109.42.8 Subject: Re: [Caml-list] BUG in unix.ml (was: strange errors when linking lwt.unix) On Fri, Mar 15, 2013 at 03:05:51PM +0000, Jeremie Dimino wrote: > On Fri, Mar 15, 2013 at 2:27 PM, oliver wrote: > > Just by your activation of signal function > > - not blocking, but handling "Sys.Signal_handle" but with the unreliable signal semantics > > this has cause the problems. > > > > signal(2) opened the pandoras box. > > Actually OCaml is using sigaction(2). It is only using signal(2) when > sigaction is not available. > > Actually there are two different things here: > > - signal disposition: this is a process-wide settings for each signal > describing how to react when it is received. It can be changed with > the [sigaction] system call (or the less portable [signal]). > - signal mask: it is a per-thread set of signals that are blocked. It > can be changed with sigprocmask. > > When a signal is received by a thread, if it is blocked it will be > pending until it is unblocked. When it is not blocked and the > threaded is waiting on an interruptible system call and the > disposition of the signal is a user-defined handler, the system call > will fail with EINTR and the handler will be invoked. > > So basically Sys.set_signal and Unix.sigprocmask are two different > things. You should block signals when you are running some code that > you don't want to be interrupted: > > # #load "unix.cma";; > # Sys.set_signal Sys.sigusr1 (Sys.Signal_handle (fun _ -> > print_endline "signal!"));; > - : unit = () > # let old_mask = Unix.sigprocmask Unix.SIG_BLOCK [Sys.sigusr1];; > val old_mask : int list = [] > # Unix.kill (Unix.getpid ()) Sys.sigusr1;; > - : unit = () > # Unix.sigprocmask Unix.SIG_SETMASK old_mask;; > signal! > - : int list = [-12] > > The man page describing all this is signal(7). [...] I don't know why you are telling me this. i did not asked about it. But if you wish to explain it to yourself, go on. Ciao, Oliver