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 F35147EE80 for ; Fri, 15 Mar 2013 16:06:00 +0100 (CET) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of jdimino@janestreet.com) identity=pra; client-ip=38.105.200.229; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="jdimino@janestreet.com"; x-sender="jdimino@janestreet.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of jdimino@janestreet.com designates 38.105.200.229 as permitted sender) identity=mailfrom; client-ip=38.105.200.229; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="jdimino@janestreet.com"; x-sender="jdimino@janestreet.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@tot-dmz-mxout1.janestreet.com) identity=helo; client-ip=38.105.200.229; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="jdimino@janestreet.com"; x-sender="postmaster@tot-dmz-mxout1.janestreet.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ag4BAN42Q1EmacjlmWdsb2JhbABDxRaBXR4OAQEBAQEICwsHFCiCKgEBBScZAQE3AQ8LCw0uIhIBBQEcBhMIiAwDpECKcoQ7AQWPIQaPFQeDQJZegR+EXokjFimELQ X-IPAS-Result: Ag4BAN42Q1EmacjlmWdsb2JhbABDxRaBXR4OAQEBAQEICwsHFCiCKgEBBScZAQE3AQ8LCw0uIhIBBQEcBhMIiAwDpECKcoQ7AQWPIQaPFQeDQJZegR+EXokjFimELQ X-IronPort-AV: E=Sophos;i="4.84,850,1355094000"; d="scan'208";a="6642457" Received: from mx5.janestreet.com (HELO tot-dmz-mxout1.janestreet.com) ([38.105.200.229]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 15 Mar 2013 16:05:59 +0100 Received: from [172.27.22.15] (helo=tot-smtp) by tot-dmz-mxout1.janestreet.com with esmtp (Exim 4.76) (envelope-from ) id 1UGWCe-0001q5-Fp for caml-list@inria.fr; Fri, 15 Mar 2013 11:05:52 -0400 Received: from tot-dmz-mxgoog1.delacy.com ([172.27.224.14] helo=mxgoog2.janestreet.com) by tot-smtp with esmtps (TLSv1:AES256-SHA:256) (Exim 4.72) (envelope-from ) id 1UGWCe-0002Wp-F6 for caml-list@inria.fr; Fri, 15 Mar 2013 11:05:52 -0400 Received: from mail-oa0-f69.google.com ([209.85.219.69]) by mxgoog2.janestreet.com with esmtp (Exim 4.76) (envelope-from ) id 1UGWCe-0002w0-C7 for caml-list@inria.fr; Fri, 15 Mar 2013 11:05:52 -0400 Received: by mail-oa0-f69.google.com with SMTP id k14so18300506oag.0 for ; Fri, 15 Mar 2013 08:05:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=google; h=x-received:mime-version:x-received:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=QVuTT4SwhtFsgVwAFXTqIuMhSKnSJGeO/SkuU5/UiVQ=; b=Y9v9+4VAFc6afa7XBESIJjG2HLLsboP5KFIr/U/lQ8zCeVsbpmwV+Z+/RBVCwTzrcp X0TV5BNY1ErqlvZHD5StkEQYIGmjDNzthOXwDwdDb/knB/X5if9jARMP/VVxD9aIiSiY X+q8FNKPNS/7YYwU2JDzaVz6KCB8NL25w5Xdo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:mime-version:x-received:in-reply-to:references:date :message-id:subject:from:to:cc:content-type:x-gm-message-state; bh=QVuTT4SwhtFsgVwAFXTqIuMhSKnSJGeO/SkuU5/UiVQ=; b=F7XStK78O6LyMF5yWTd8nfZlwBNBV/XfVmj12WxqVHoL7ifCd8BsPkvOAnhTSLgR+j uri9ePM+U2wor/t81eAP1jbQ9qI1VixFcVBiY/oXWyvUhbzE2CNQ5iyg1W32ZnLNIDBg IP6Qf1az6haTkJhkz/2mpeTDyMfjaxEi0WuB/r5mDc/cDb37oIHhkZI6UHGZGdj1pv4B sbnD+CobOZqz2Xt1v455GznNh92sQEre2BMbohXikOHTzuvjfIFjkgdnsCpruzyMoVkM 9J6EJipNcs/feXSYvuIKMzSx2QhJBwSkkef97/mR8UmGJ4LEN8j/yiL5T6wpOeJeJ/UC Anug== X-Received: by 10.50.30.69 with SMTP id q5mr1334717igh.1.1363359951954; Fri, 15 Mar 2013 08:05:51 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.50.30.69 with SMTP id q5mr1334711igh.1.1363359951852; Fri, 15 Mar 2013 08:05:51 -0700 (PDT) Received: by 10.50.29.48 with HTTP; Fri, 15 Mar 2013 08:05:51 -0700 (PDT) In-Reply-To: <20130315142715.GC4697@siouxsie> References: <5142E780.7060806@hars.de> <20130315124345.GB3262@siouxsie> <20130315141735.GA4697@siouxsie> <20130315142715.GC4697@siouxsie> Date: Fri, 15 Mar 2013 15:05:51 +0000 Message-ID: From: Jeremie Dimino To: oliver Cc: caml-list@inria.fr, ocsigen@inria.fr Content-Type: text/plain; charset=ISO-8859-1 X-Gm-Message-State: ALoCoQn97MAu9y1WIGJZHO2QcmKUv1fUfU3aN94bJ5WHBz5IUjcPDg35Y8uJcUnCfD9SQZsA7GxScqCIOF4l5Pg4ISYK5t+eue1i6Yt2Cv+TVN/+PFcHCPvPC2J0mtY6osimriJr9Pq5r79x1FZ/fHEgGfSrX28l7g== Subject: Re: [Caml-list] BUG in unix.ml (was: strange errors when linking lwt.unix) 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). Jeremie