From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andy Wingo Newsgroups: gmane.lisp.guile.devel Subject: Re: wip-threads-and-fork Date: Mon, 27 Feb 2012 10:44:11 +0100 Message-ID: <87mx848vbo.fsf@pobox.com> References: <877gzx0ye0.fsf@pobox.com> <878vjupmw7.fsf@pobox.com> <87ipixoajf.fsf@pobox.com> <87boopo7cr.fsf@pobox.com> <87aa48mszu.fsf@pobox.com> <87fwdx1cdf.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1330335870 3071 80.91.229.3 (27 Feb 2012 09:44:30 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 27 Feb 2012 09:44:30 +0000 (UTC) Cc: guile-devel@gnu.org To: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Mon Feb 27 10:44:28 2012 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1S1x87-00074b-Mp for guile-devel@m.gmane.org; Mon, 27 Feb 2012 10:44:27 +0100 Original-Received: from localhost ([::1]:36035 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S1x87-0006Pd-B2 for guile-devel@m.gmane.org; Mon, 27 Feb 2012 04:44:27 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:38126) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S1x83-0006PX-AJ for guile-devel@gnu.org; Mon, 27 Feb 2012 04:44:25 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S1x7x-00075q-3n for guile-devel@gnu.org; Mon, 27 Feb 2012 04:44:23 -0500 Original-Received: from a-pb-sasl-sd.pobox.com ([74.115.168.62]:45435 helo=sasl.smtp.pobox.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S1x7w-00075j-VX; Mon, 27 Feb 2012 04:44:17 -0500 Original-Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-sd.pobox.com (Postfix) with ESMTP id 390CB9DE3; Mon, 27 Feb 2012 04:44:16 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type:content-transfer-encoding; s=sasl; bh=24lfb6LhLotv 6zNsn2tIYIv3LAQ=; b=udV+nuhsieClgPUOMhOE3zi+aPihbsGugjgsH1FHH81B v+5eC11rJmiMVdbNVrq+x+VzYjvaR8ODbE1zHLx4uot2e3GYvCXXAMbC/7Oe9tSs Htp+C3rZhX1e3aV47I4gjCLzhB3ryNxUJWhSNnLbm0yKjLZ/mSfIbC44bPmKqQA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type:content-transfer-encoding; q=dns; s=sasl; b=mZAn/+ jvaIkx/ZAsVX8maFt17MRtLYQ/2fTRN7dgjyZw9aEdP9ScW9AXvx8xjBwksLdBYY fCRpAUu5Qw/kUXmKLBkInZljOjAVSTh7uFvCeCA99uhnBS7oPFZTWaJq7iqQOIb/ khCMODdEx28x4u5np4knKdWNiV6UCuVL0lU6o= Original-Received: from a-pb-sasl-sd.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-sd.pobox.com (Postfix) with ESMTP id 31CB09DE2; Mon, 27 Feb 2012 04:44:16 -0500 (EST) Original-Received: from badger (unknown [85.50.113.138]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by a-pb-sasl-sd.pobox.com (Postfix) with ESMTPSA id 6B1299DE1; Mon, 27 Feb 2012 04:44:15 -0500 (EST) In-Reply-To: <87fwdx1cdf.fsf@gnu.org> ("Ludovic =?utf-8?Q?Court=C3=A8s=22'?= =?utf-8?Q?s?= message of "Sun, 26 Feb 2012 23:03:08 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) X-Pobox-Relay-ID: 9C8BD2D0-6127-11E1-822A-65B1DE995924-02397024!a-pb-sasl-sd.pobox.com X-detected-operating-system: by eggs.gnu.org: Solaris 10 (beta) X-Received-From: 74.115.168.62 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:13960 Archived-At: On Sun 26 Feb 2012 23:03, ludo@gnu.org (Ludovic Court=C3=A8s) writes: > Andy Wingo skribis: > >> + if (scm_ilength (scm_all_threads ()) !=3D 1) >> + /* Other threads may be holding on to resources that Guile need= s -- >> + it is not safe to permit one thread to fork while others are >> + running. >> + >> + In addition, POSIX clearly specifies that if a multi-threaded >> + program forks, the child must only call functions that are >> + async-signal-safe. We can't guarantee that in general. The= best >> + we can do is to allow forking only very early, before any ca= ll to >> + sigaction spawns the signal-handling thread. */ >> + SCM_MISC_ERROR ("attempt to fork while multiple threads are run= ning", >> + SCM_EOL); > > Just like fork(2) lets one shoot themself in the foot, I think this is > beyond libguile=E2=80=99s scope. After all, libguile just wraps the OS > features, however crippled they may be. Dunno. That is certainly the case for things like close-fdes, and the FFI. But if someone really wants an unsafe fork, the FFI can give it to them, right? Keep in mind that portably speaking, you can't even call `malloc' in the child, if you forked a program with multiple threads. Primitive-fork is much less necessary now that open-process, the most important use case, has been rewritten in C. Finally, I think it's particularly important to constrain primitive-fork because it prevents composition of various modules. If I have a module that uses futures, and a module that forks, I can't compose them. Andy --=20 http://wingolog.org/