From 73b132bf9b6146e3b6c1a474eda93649d5f14719 Mon Sep 17 00:00:00 2001 From: malc Date: Sat, 10 Mar 2012 04:33:54 +0400 Subject: [PATCH] Make Cygwin happy again (no spawn.h) --- link.c | 10 +++++++++- main.ml | 20 ++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/link.c b/link.c index 78b0501..4a31054 100644 --- a/link.c +++ b/link.c @@ -2,7 +2,6 @@ #include #include #include -#include #include #include #include @@ -15,6 +14,8 @@ #ifdef __CYGWIN__ #include /* FIONREAD */ +#else +#include #endif #include @@ -2560,6 +2561,12 @@ static int pipespan (FILE *f, fz_text_span *span, int a, int b) return 0; } +#ifdef __CYGWIN__ +value ml_popen (value UNUSED u1, value UNUSED u2) +{ + caml_failwith ("ml_popen not implemented under Cygwin"); +} +#else CAMLprim value ml_popen (value command_v, value fds_v) { CAMLparam2 (command_v, fds_v); @@ -2607,6 +2614,7 @@ CAMLprim value ml_popen (value command_v, value fds_v) } CAMLreturn (Val_unit); } +#endif CAMLprim value ml_copysel (value fd_v, value ptr_v) { diff --git a/main.ml b/main.ml index b8f4260..9dcc39c 100644 --- a/main.ml +++ b/main.ml @@ -111,6 +111,26 @@ let platform_to_string = function let platform = platform ();; +let popen cmd fda = + if platform = Pcygwin + then ( + let sh = "/bin/sh" in + let args = [|sh; "-c"; cmd|] in + let rec std si so se = function + | [] -> si, so, se + | (fd, 0) :: rest -> std fd so se rest + | (fd, -1) :: rest -> + Unix.set_close_on_exec fd; + std si so se rest + | (_, n) :: _ -> + failwith ("unexpected fdn in cygwin popen " ^ string_of_int n) + in + let si, so, se = std Unix.stdin Unix.stdout Unix.stderr fda in + ignore (Unix.create_process sh args si so se) + ) + else popen cmd fda; +;; + type x = int and y = int and tilex = int -- 2.11.4.GIT