caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Creating a pipeline under windows
@ 2008-04-15  4:07 jamesj
  0 siblings, 0 replies; only message in thread
From: jamesj @ 2008-04-15  4:07 UTC (permalink / raw)
  To: caml-list

[-- Attachment #1: Type: text/plain, Size: 785 bytes --]

I am trying to write a cross-platform program that will simulate the effect 
of the following shell command:

  prog1 | prog2

i.e. create a pipeline. The following code

let () =
  let r,w = Unix.pipe () in
  Unix.set_close_on_exec w;
  let w_pid = Unix.create_process "prog2" [|"prog2"|] r Unix.stdout 
Unix.stderr in
  Unix.close r;
  let r_pid = Unix.create_process "prog1" [|"prog1"|] Unix.stdin w 
Unix.stderr in
  Unix.close w;
  assert (snd (Unix.waitpid [] w_pid) = Unix.WEXITED 0 &&
          snd (Unix.waitpid [] r_pid) = Unix.WEXITED 0)

works fine on linux but not on windows (using the native port). I tried to 
comment out the Unix.set_close_on_exec and/or the Unix.close lines but it 
does not help. I was not successful with the Unix.open_process_* functions 
either.

[-- Attachment #2: Type: text/html, Size: 1637 bytes --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-04-15  4:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-15  4:07 Creating a pipeline under windows jamesj

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).