1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 03:40:34 +02:00

Fix hanging of popen.test

The "open-output-pipe":"no duplicate" test has been hanging, on and
off, and not completely reliably, for a few years.  It's now doing so
fairly reliably for me, and investigation shows that

- the child shell process is in a tight loop (99% CPU)

- the parent Guile process is stuck calling waitpid().

The problem is that the child hasn't got the SIGPIPE that the test
intends, and so is continuing to echo "closed" forever; and Guile is
waiting for it to terminate, forever.

I haven't fully debugged the SIGPIPE problem, but it sounds very like
what Chet Ramey describes here:
http://old.nabble.com/Re%3A-SIGPIPE-not-properly-reset-with-%27trap---PIPE%27-p20985595.html.

(And my version of bash is 3.2.39.)

So, a fix should be to use something other than shell to implement the
child; and it appears that this works.

* check-guile.in (TEST_SUITE_DIR): Export.

* test-suite/tests/popen-child.scm: New script file.

* test-suite/tests/popen.test ("open-output-pipe", "no duplicate"):
  Use Guile for the child process, instead of shell.
This commit is contained in:
Neil Jerram 2010-06-10 23:40:41 +01:00
parent d5e0eb5797
commit 6069e97331
3 changed files with 9 additions and 2 deletions

View file

@ -15,6 +15,7 @@ top_builddir=@top_builddir_absolute@
top_srcdir=@top_srcdir_absolute@ top_srcdir=@top_srcdir_absolute@
TEST_SUITE_DIR=${top_srcdir}/test-suite TEST_SUITE_DIR=${top_srcdir}/test-suite
export TEST_SUITE_DIR
if [ x"$1" = x-i ] ; then if [ x"$1" = x-i ] ; then
guile=$2 guile=$2

View file

@ -0,0 +1,5 @@
(close-port (current-input-port))
(let loop ()
(display "closed\n" (current-error-port))
(force-output (current-error-port))
(loop))

View file

@ -167,8 +167,9 @@
(let* ((c2p (pipe)) (let* ((c2p (pipe))
(port (with-error-to-port (cdr c2p) (port (with-error-to-port (cdr c2p)
(lambda () (lambda ()
(open-output-pipe (open-output-pipe (format #f
"exec 0</dev/null; while true; do echo closed 1>&2; done"))))) "guile -s ~a/tests/popen-child.scm"
(getenv "TEST_SUITE_DIR")))))))
(close-port (cdr c2p)) ;; write side (close-port (cdr c2p)) ;; write side
(with-epipe (with-epipe
(lambda () (lambda ()