summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-06-20 19:19:31 -0700
committerKaz Kylheku <kaz@kylheku.com>2021-06-20 19:19:31 -0700
commit714611bd0ca66e2674d0aee8034dae355add9f57 (patch)
tree54e8843b56139e91122283c8cdb1c3c7f6c6b5e2
parenta93ca48fd3bad30132dff3df62637a6d8dcf28e2 (diff)
downloadtxr-714611bd0ca66e2674d0aee8034dae355add9f57.tar.gz
txr-714611bd0ca66e2674d0aee8034dae355add9f57.tar.bz2
txr-714611bd0ca66e2674d0aee8034dae355add9f57.zip
subprocesses: cygwin fixes.
* stream.c (fds_subst, fds_swizzle, fds_restore): These functions are used on Cygwin by some functions that are based on spawn, and so must be avaiable. * tests/018/process.tl: Two fixes here. Firstly, the 1>&1 redirection in one of the tests should be 1>&2 on all platforms. That a temporary edit left behind from massaging the tests and the code. Secondly, some weird results are observed on Cygwin. The communication with the child sees an extra carriage return and space sneak in. I'm just codifying this as Cygwin's way of passing the test case; it's likely unfixable at the application level.
-rw-r--r--stream.c4
-rw-r--r--tests/018/process.tl12
2 files changed, 11 insertions, 5 deletions
diff --git a/stream.c b/stream.c
index c38df097..c5991bd3 100644
--- a/stream.c
+++ b/stream.c
@@ -4263,7 +4263,7 @@ static int fds_getfd(val stream, val self)
return fd_sub;
}
-#if !HAVE_FORK_STUFF
+#if !HAVE_FORK_STUFF || HAVE_WSPAWN || HAVE_SPAWN
static int fds_subst(int fd_sub, int fd_std, val self)
{
if (fd_sub == fd_std)
@@ -4302,7 +4302,7 @@ static void fds_prepare(struct save_fds *fds, int flags, val self)
fds->suberr = fds_getfd(std_error, self);
}
-#if !HAVE_FORK_STUFF
+#if !HAVE_FORK_STUFF || HAVE_WSPAWN || HAVE_SPAWN
static void fds_swizzle(struct save_fds *fds, int flags, val self)
{
if ((flags & FDS_IN) != 0)
diff --git a/tests/018/process.tl b/tests/018/process.tl
index b34047b2..1b3780ac 100644
--- a/tests/018/process.tl
+++ b/tests/018/process.tl
@@ -13,6 +13,12 @@
^(with-stream (s (open-subprocess nil "r" nil (lambda () ,*forms)))
(get-string s)))
-(mtest
- (fcmd (let ((*stdout* *stdnull*)) (sh "echo foo"))) ""
- (fcmd (let ((*stderr* *stdout*)) (sh "echo foo 1>&1"))) "foo\n")
+(caseq (os-symbol)
+ ((:cygwin :cygnal)
+ (mtest
+ (fcmd (let ((*stdout* *stdnull*)) (sh "echo foo"))) ""
+ (fcmd (let ((*stderr* *stdout*)) (sh "echo foo 1>&2"))) "foo \r\n"))
+ (t
+ (mtest
+ (fcmd (let ((*stdout* *stdnull*)) (sh "echo foo"))) ""
+ (fcmd (let ((*stderr* *stdout*)) (sh "echo foo 1>&2"))) "foo\n")))