From 36232eb7e1323832df24031957e647ca8675a2e9 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sat, 19 Jun 2021 13:01:42 -0700 Subject: system: stop using popen if we have fork. On all the platforms on which TXR is regularly built, there is fork, including the Windows port via Cygwin. We therefore don't have to be using popen for the open-command function. The handling the stream redirection will be more efficient if we implement open-command in terms of open-process, and the special mode string extensions for redirection like ">21" will work, too. * stream.c (fds_subst, fds_swizzle): Define these functions only for !HAVE_FORK_STUFF platforms. (open_command): popen-based implementation moved down into a section of code for !HAVE_FORK_STUFF platforms. A separate implementation is written for HAVE_FORK_STUFF platforms which passes the command to an appropriate Windows native or POSIX interpreter. * utf8.c (w_popen): Nothing but open-command calls this function, so we don't need it on HAVE_FORK_STUFF platforms. Wrap with #if. * utf8.h (w_popen): wrap with #if. --- utf8.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'utf8.c') diff --git a/utf8.c b/utf8.c index 0d484f4f..b8650fdd 100644 --- a/utf8.c +++ b/utf8.c @@ -374,6 +374,7 @@ FILE *w_fopen(const wchar_t *wname, const wchar_t *wmode) return f; } +#if !HAVE_FORK_STUFF FILE *w_popen(const wchar_t *wcmd, const wchar_t *wmode) { char *cmd = utf8_dup_to(wcmd); @@ -383,6 +384,7 @@ FILE *w_popen(const wchar_t *wcmd, const wchar_t *wmode) free(mode); return f; } +#endif FILE *w_freopen(const wchar_t *wname, const wchar_t *wmode, FILE *fold) { -- cgit v1.2.3