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 mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 245307F891 for ; Thu, 20 Mar 2014 00:21:39 +0100 (CET) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of info@gerd-stolpmann.de) identity=pra; client-ip=212.227.126.130; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="info@gerd-stolpmann.de"; x-sender="info@gerd-stolpmann.de"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of info@gerd-stolpmann.de) identity=mailfrom; client-ip=212.227.126.130; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="info@gerd-stolpmann.de"; x-sender="info@gerd-stolpmann.de"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of postmaster@moutng.kundenserver.de designates 212.227.126.130 as permitted sender) identity=helo; client-ip=212.227.126.130; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="info@gerd-stolpmann.de"; x-sender="postmaster@moutng.kundenserver.de"; x-conformance=sidf_compatible; x-record-type="v=spf1" X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: As4BAKIlKlPU436ClGdsb2JhbABSCINBg164D4c0gRsWDgEBAQEHCwsJEiqCJQEBAQQjMiQQCxgqAgJXBhMJh3QJrUSiaBeJI4RsMCYHgi5BgUkEjyKPbAWPEg X-IPAS-Result: As4BAKIlKlPU436ClGdsb2JhbABSCINBg164D4c0gRsWDgEBAQEHCwsJEiqCJQEBAQQjMiQQCxgqAgJXBhMJh3QJrUSiaBeJI4RsMCYHgi5BgUkEjyKPbAWPEg X-IronPort-AV: E=Sophos;i="4.97,689,1389740400"; d="asc'?scan'208";a="63704377" Received: from moutng.kundenserver.de ([212.227.126.130]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES128-SHA; 20 Mar 2014 00:21:38 +0100 Received: from office1.lan.sumadev.de (dslb-088-069-137-091.pools.arcor-ip.net [88.69.137.91]) by mrelayeu.kundenserver.de (node=mreue007) with ESMTP (Nemesis) id 0LrDwG-1X7ULe0JZc-0133ll; Thu, 20 Mar 2014 00:21:38 +0100 Received: from [192.168.10.103] (ip-37-201-194-198.unitymediagroup.de [37.201.194.198]) by office1.lan.sumadev.de (Postfix) with ESMTPSA id 23B68DC270; Thu, 20 Mar 2014 00:21:37 +0100 (CET) Message-ID: <1395271296.27397.11.camel@zotac> From: Gerd Stolpmann To: Jesper Louis Andersen Cc: Anders Peter Fugmann , caml-list Date: Thu, 20 Mar 2014 00:21:36 +0100 In-Reply-To: References: <532A0A5E.6070107@fugmann.net> Content-Type: multipart/signed; micalg="pgp-sha1"; protocol="application/pgp-signature"; boundary="=-4I2/hK6vGu0jIBY05fHA" X-Mailer: Evolution 3.2.3-0ubuntu6 Mime-Version: 1.0 X-Provags-ID: V02:K0:bVGzJ21MvN7/s05q/tGeUkNjkLB5ecjFsdXIpQTlTpW 7iliIDdFV6Fb+fC+DtNoFedLSoDG2MU7F8Q86/XReQspvRpRCF lYvFxrAfuj19ctB4O2Zue8D5zPJt1Gepu22wZapVyviy9xnQ7O Umo98DNTbwl9EBuzBEoLNRGY1KHPChVipDGV4hv1SMs7r82MJR pLLUfJ4nfYC8yAgp6YvmFfGAWg5YcdtEnK3sb4BMx6QSFsKx0v Fw6ro1uYya+/kulYHIieCETc4lS/Ccv220qLfKNyxWWLYAvQmm zBcdif11qvTo3on64CMkIEhYvxJwGrShp9FB/FvNPVeDrtTcT4 Srp4yj14nV6wZ05cB/ZYF+RqZUypH75ujEwSNAnKz Subject: Re: [Caml-list] Bug when printing from signal handlers? --=-4I2/hK6vGu0jIBY05fHA Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable OCaml printing isn't printf in C - it calls directly write() and is always possible. OCaml signal handlers aren't signal handlers from the C viewpoint: When the signal is caught, a flag in the OCaml runtime is set, and this flag is regularly checked by the running code. (I.e. what you suggest is already done in the runtime.) So, I'd say this is a bug in the OCaml runtime. The bug goes away when you print to a different channel from the signal handler, so it looks like channels and signal handlers have some unwanted effect on each other. Gerd Am Mittwoch, den 19.03.2014, 23:19 +0100 schrieb Jesper Louis Andersen: >=20 > On Wed, Mar 19, 2014 at 10:21 PM, Anders Peter Fugmann > wrote: > Is printing from a signal handler illegal? >=20 > FWIW, that is illegal in some operating systems. I have seen it in one > case at least: >=20 >=20 > * Linux with threads. printf in C is protected by a mutex. Suppose we > are inside the printf, with the mutex locked and then we get a signal. > We run the handler, and it wants to print out debug information. > Welcome deadlock! > * Many system calls are not safe in the signal handler. FreeBSD has a > list in sigaction(2) for instance. See >=20 >=20 >=20 > http://www.freebsd.org/cgi/man.cgi?query=3Dsigaction&apropos=3D0&sektion= =3D0&manpath=3DFreeBSD+10.0-RELEASE&arch=3Ddefault&format=3Dhtml >=20 >=20 > In practice, you should probably just set a flag in the signal handler > and then handle that in a main loop of the program. Doing advanced > stuff in a signal handler is usually dangerous non-compatible > territory. >=20 >=20 >=20 > --=20 > J. --=20 ------------------------------------------------------------ Gerd Stolpmann, Darmstadt, Germany gerd@gerd-stolpmann.de My OCaml site: http://www.camlcity.org Contact details: http://www.camlcity.org/contact.html Company homepage: http://www.gerd-stolpmann.de ------------------------------------------------------------ --=-4I2/hK6vGu0jIBY05fHA Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iQEcBAABAgAGBQJTKiaAAAoJEAaM4b9ZLB5T7FgH/2rWGUVxIdC/yF+ogWkuM52y Cxor2gdQn8O5GSno8+oSJVcc4+Yux5ioTqfuH2znuuVFPx+HwS+lc5nQDySdBk5Y GAAo0Ov/KC/pMYT83oaGZQc1hkQUG6Va5RufpKxOzj4nxq4JigdasEjvNbBuLoPk qqG4H8669Ck/2WBiHx9uQS718oYepnKPpZR7XaeGUhR6iJISME7Xaz9rGzpFXHPT ZGxw4B87Kyy3vl8BvMknpuoIQ1iJzmG6ioGSCu0+ZNLa50NpM56jgA55HsAh8uNI MVxzdthjNb2IDtwpAuLyOkOzQqIjtJUzQJb8U8pm1tJuUq30Tzvf91/uKjMvY20= =MEDO -----END PGP SIGNATURE----- --=-4I2/hK6vGu0jIBY05fHA--