diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2014-03-16 00:09:30 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2014-03-16 00:10:42 -0700 |
commit | aca7c64aa69a4e14a2dd57779cd206a5aa15f649 (patch) | |
tree | 6a700564ae7356241a9d29f5fe7fc8c4a0ae858e /stream.c | |
parent | ef14bd0e49bec4025b80bdc01638b7a34b7778de (diff) | |
download | txr-aca7c64aa69a4e14a2dd57779cd206a5aa15f649.tar.gz txr-aca7c64aa69a4e14a2dd57779cd206a5aa15f649.tar.bz2 txr-aca7c64aa69a4e14a2dd57779cd206a5aa15f649.zip |
* configure: Detect _wspawn* functions.
* stream.c (run): Implement using _wspawnvp on MinGW.
Diffstat (limited to 'stream.c')
-rw-r--r-- | stream.c | 24 |
1 files changed, 24 insertions, 0 deletions
@@ -2338,6 +2338,30 @@ static val run(val name, val args) return status == 0 ? zero : nil; } } +#elif HAVE_WSPAWN +static val run(val command, val args) +{ + const wchar_t **wargv = 0; + val iter; + int i, nargs, status; + + args = default_bool_arg(args); + nargs = c_num(length(args)) + 1; + + wargv = (const wchar_t **) chk_malloc((nargs + 2) * sizeof *wargv); + + for (i = 0, iter = cons(command, args); iter; i++, iter = cdr(iter)) + wargv[i] = c_str(car(iter)); + wargv[i] = 0; + + status = _wspawnvp(_P_WAIT, c_str(command), wargv); + + for (i = 0; i < nargs; i++) + free((void *) wargv[i]); + free((void *) wargv); + + return (status < 0) ? nil : num(status); +} #else static val run(val command, val args) { |