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: "no duplicate" in `popen.test' Date: Mon, 19 May 2008 10:53:18 +0200 Message-ID: <877idqlloh.fsf@gnu.org> References: <87wso5livc.fsf@gnu.org> <87od9dc657.fsf@ossau.uklinux.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1211187352 10973 80.91.229.12 (19 May 2008 08:55:52 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 19 May 2008 08:55:52 +0000 (UTC) To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Mon May 19 10:56:30 2008 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Jy1AI-0007h2-PN for guile-devel@m.gmane.org; Mon, 19 May 2008 10:56:19 +0200 Original-Received: from localhost ([127.0.0.1]:42077 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Jy19X-0002Ms-Sm for guile-devel@m.gmane.org; Mon, 19 May 2008 04:55:32 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Jy17e-0001Xv-U7 for guile-devel@gnu.org; Mon, 19 May 2008 04:53:35 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Jy17c-0001Wn-L2 for guile-devel@gnu.org; Mon, 19 May 2008 04:53:33 -0400 Original-Received: from [199.232.76.173] (port=48940 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Jy17b-0001WT-ME for guile-devel@gnu.org; Mon, 19 May 2008 04:53:31 -0400 Original-Received: from main.gmane.org ([80.91.229.2]:47851 helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Jy17b-0007Up-71 for guile-devel@gnu.org; Mon, 19 May 2008 04:53:31 -0400 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1Jy17V-0002NX-9r for guile-devel@gnu.org; Mon, 19 May 2008 08:53:25 +0000 Original-Received: from 193.50.110.120 ([193.50.110.120]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 19 May 2008 08:53:25 +0000 Original-Received: from ludo by 193.50.110.120 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 19 May 2008 08:53:25 +0000 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 79 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 193.50.110.120 X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 1 Prairial an 216 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: 821D 815D 902A 7EAB 5CEE D120 7FBA 3D4F EB1F 5364 X-OS: i686-pc-linux-gnu User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux) Cancel-Lock: sha1:eh1X0KK5PjaUcztln62r2kXa1HE= X-detected-kernel: by monty-python.gnu.org: Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:7253 Archived-At: --=-=-= Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Hi, Neil Jerram writes: > ludo@gnu.org (Ludovic Courtès) writes: > >> That "no duplicate" test in `popen.test' leaves a zombie behind it [0]. >> The fix would be to `waitpid' the process created by `open-input-pipe' >> (see attached patch), but that makes it hang, waiting for "sleep 999" to >> complete. > > I've attached an alternative possible solution, using feedback from > the parent to the child to avoid needing the long sleep. Can you apply this patch? I have a slightly modified version in NixOS, which is your patch + the using `read' in the second "no duplicate" test. Thanks, Ludovic. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=popen-zombie.patch Content-Description: The patch Index: guile/test-suite/tests/popen.test =================================================================== RCS file: /sources/guile/guile/guile-core/guile/test-suite/tests/popen.test,v retrieving revision 1.3.2.2 diff -u -r1.3.2.2 popen.test --- guile/test-suite/tests/popen.test 25 Aug 2006 01:21:39 -0000 1.3.2.2 +++ guile/test-suite/tests/popen.test 18 Mar 2008 20:18:08 -0000 @@ -1,6 +1,6 @@ ;;;; popen.test --- exercise ice-9/popen.scm -*- scheme -*- ;;;; -;;;; Copyright 2003, 2006 Free Software Foundation, Inc. +;;;; Copyright 2003, 2006, 2008 Free Software Foundation, Inc. ;;;; ;;;; This library is free software; you can redistribute it and/or ;;;; modify it under the terms of the GNU Lesser General Public @@ -81,12 +81,15 @@ (let* ((pair (pipe)) (port (with-error-to-port (cdr pair) (lambda () - (open-input-pipe - "exec 1>/dev/null; echo closed 1>&2; exec 2>/dev/null; sleep 999"))))) + (open-input-output-pipe + "exec 1>/dev/null; echo closed 1>&2; exec 2>/dev/null; read"))))) (close-port (cdr pair)) ;; write side - (and (char? (read-char (car pair))) ;; wait for child to do its thing - (char-ready? port) - (eof-object? (read-char port)))))) + (let ((result (and (char? (read-char (car pair))) ;; wait for child to do its thing + (char-ready? port) + (eof-object? (read-char port))))) + (display "hello!\n" port) + (close-pipe port) + result)))) ;; ;; open-output-pipe @@ -132,7 +135,7 @@ (port (with-error-to-port (cdr pair) (lambda () (open-output-pipe - "exec 0&2; exec 2>/dev/null; sleep 999"))))) + "exec 0&2; exec 2>/dev/null; read"))))) (close-port (cdr pair)) ;; write side (and (char? (read-char (car pair))) ;; wait for child to do its thing (catch 'system-error --=-=-=--