This test, which seems quite complicated to fix, causes the MinGW build
to hang. Disable it for now, but, come back to it later.
* test-suite/tests/popen.test (mingw?): new constant
(no duplicate): disable for mingw, for now
* module/ice-9/popen.scm (open-process)[unbuffered, fdes-pair]: New
procedures.
Use them. Return unbuffered ports.
* test-suite/tests/popen.test ("open-pipe*"): New test prefix.
Reported by Eli Zaretskii <eliz@gnu.org>.
* test-suite/test-suite/lib.scm (%null-device): New variable.
* test-suite/tests/c-api.test (egrep): Use %NULL-DEVICE instead of
/dev/null.
* test-suite/tests/popen.test ("open-input-pipe")["no duplicate"]:
Likewise.
Fixes <http://bugs.gnu.org/13848>.
Reported by Jan Schukat <shookie@email.de>.
* configure.ac: Rename `HAVE_FORK' conditional to `BUILD_ICE_9_POPEN'.
Set it when both $enable_posix and $ac_cv_func_fork are true.
* libguile/posix.c (scm_init_posix): Add the `fork' feature.
* doc/ref/api-options.texi (Common Feature Symbols): Add `fork'.
* doc/ref/posix.texi (Pipes): Add footnote mentioning the `fork'
feature.
* module/Makefile.am (SCRIPTS_SOURCES): Make `scripts/autofrisk.scm' and
`scripts/scan-api.scm' conditional on `BUILD_ICE_9_POPEN'.
* test-suite/tests/popen.test (if-supported): New macro.
Wrap body in `if-supported'.
* test-suite/tests/popen.test (open-input-pipe no-duplicate): Pass
"read REPLY" command instead of "read" to the subshell, for improved
portability. In particular, it is needed when /bin/sh is dash.
(open-output-pipe no-duplicate): Pass "exec guile [...]" instead of
"guile [...]" to the subshell, to ensure that the subshell will not
run guile as a subprocess while holding a duplicate of STDIN, which
would cause this test to fail. This is needed when /bin/sh is dash.
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.
Thanks to Greg Troxel for reporting, and Barry Fishman for the
explanation and fix.
* test-suite/tests/popen.test ("open-input-pipe"): Use shell function
`read' with an explicit argument, as apparently not all shells
support read with no argument.
On the one hand we want the child process in these tests to exit. On
the other, we don't want it to exit before the parent Guile code has
tested the relevant condition (EOF in the first test, broken pipe in
the second) - because these conditions would obviously be true if the
child had already exited, and that's not what we're trying to test
here. We're trying to test getting EOF and broken pipe while the
child process is still alive.
* test-suite/tests/popen.test (open-input-pipe:no duplicate): Add
another pipe from parent to child, so that the child can finish by
reading from this. Then the parent controls the child lifetime by
writing to this pipe.
* test-suite/tests/popen.test (open-output-pipe:no duplicate): Add
another pipe from child to parent, and have the child finish by
endlessly writing into this. Then the parent controls the child
lifetime by closing its end of the pipe, causing a broken pipe in
the child.