From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: ludo@gnu.org (Ludovic =?iso-8859-1?Q?Court=E8s?=) Newsgroups: gmane.lisp.guile.devel Subject: Re: wip-threads-and-fork Date: Sun, 26 Feb 2012 23:00:05 +0100 Message-ID: <87sjhx1cii.fsf@gnu.org> References: <877gzx0ye0.fsf@pobox.com> <878vjupmw7.fsf@pobox.com> <87ipixoajf.fsf@pobox.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: dough.gmane.org 1330293624 11553 80.91.229.3 (26 Feb 2012 22:00:24 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 26 Feb 2012 22:00:24 +0000 (UTC) To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Sun Feb 26 23:00:23 2012 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1S1m8l-0005eX-EK for guile-devel@m.gmane.org; Sun, 26 Feb 2012 23:00:23 +0100 Original-Received: from localhost ([::1]:52338 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S1m8l-00061h-1p for guile-devel@m.gmane.org; Sun, 26 Feb 2012 17:00:23 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:36587) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S1m8i-00061c-Kk for guile-devel@gnu.org; Sun, 26 Feb 2012 17:00:21 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S1m8h-0000L5-FI for guile-devel@gnu.org; Sun, 26 Feb 2012 17:00:20 -0500 Original-Received: from plane.gmane.org ([80.91.229.3]:59034) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S1m8h-0000L1-9V for guile-devel@gnu.org; Sun, 26 Feb 2012 17:00:19 -0500 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1S1m8c-0005cU-Lx for guile-devel@gnu.org; Sun, 26 Feb 2012 23:00:14 +0100 Original-Received: from reverse-83.fdn.fr ([80.67.176.83]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 26 Feb 2012 23:00:14 +0100 Original-Received: from ludo by reverse-83.fdn.fr with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 26 Feb 2012 23:00:14 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 52 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: reverse-83.fdn.fr X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 8 =?iso-8859-1?Q?Vent=F4se?= an 220 de la =?iso-8859-1?Q?R=E9volution?= X-PGP-Key-ID: 0xEA52ECF4 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 83C4 F8E5 10A3 3B4C 5BEA D15D 77DD 95E2 EA52 ECF4 X-OS: x86_64-unknown-linux-gnu User-Agent: Gnus/5.110018 (No Gnus v0.18) Emacs/24.0.93 (gnu/linux) Cancel-Lock: sha1:O8J7m4QT7PPy8DAOqoej3PsJ5m8= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 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:13954 Archived-At: Hi, Andy Wingo skribis: > A guile built without > threads may fork to its heart's content. However a guile built with > threads -- the default, recommended configuration -- should not call > primitive-fork. That’s a strong statement. When the only threads are the main thread and the signal thread, everything’s alright. For example, this works fine on GNU/Linux: --8<---------------cut here---------------start------------->8--- (let ((p (primitive-fork))) (case p ((0) (sigaction SIGINT (lambda args (format #t "kid ~a got ~a~%" (getpid) args) (exit 0))) (let loop () (loop)) (exit 1)) (else (sleep 2) (kill p SIGINT) (format #t "killed ~a~%" p) (waitpid p)))) --8<---------------cut here---------------end--------------->8--- It works because the signal thread is stuck in a read(2) with no lock taken. Things that don’t work include this: --8<---------------cut here---------------start------------->8--- (use-modules (ice-9 futures)) (let* ((f (future (begin (sleep 4) (getpid)))) (p (primitive-fork))) (case p ((0) (format #t "kid -> ~a~%" (touch f))) (else (format #t "parent -> ~a~%" (touch f)) (waitpid p)))) --8<---------------cut here---------------end--------------->8--- Here the child waits forever because it has only one thread. As for popen, that’s a bug (or undocumented limitation) of (ice-9 futures) itself, more than anything else. Ludo’.