From: Clinton Ebadi Date: Tue, 6 May 2014 23:19:17 +0000 (-0400) Subject: Slave.run: run a command using Unix.execute X-Git-Tag: release_20140509~7 X-Git-Url: https://git.hcoop.net/hcoop/domtool2.git/commitdiff_plain/dfd19067c2b670d13415a04291caaa51b025d3d6?hp=2b75bae8ada47b59140ee0eebf7de424c0008431 Slave.run: run a command using Unix.execute Similar to Slave.shell, only it passes the arguments list directly to Unix.execute. --- diff --git a/src/slave.sig b/src/slave.sig index 7471d86..bfe5786 100644 --- a/src/slave.sig +++ b/src/slave.sig @@ -46,6 +46,7 @@ signature SLAVE = sig val shell : string list -> bool val shellF : string list * (string -> string) -> unit val shellOutput : string list -> string option + val run : string * string list -> bool val concatTo : (string -> bool) -> string -> unit (* Search through the result configuration hierarchy for all files matching diff --git a/src/slave.sml b/src/slave.sml index ba31da8..7e3f9d8 100644 --- a/src/slave.sml +++ b/src/slave.sml @@ -82,6 +82,20 @@ fun shellF (ss, msg) = ErrorMsg.error NONE (msg s) end +fun run (program, argv) = + let + val proc = Unix.execute (program, argv) + + fun loop inf = + case TextIO.inputLine inf of + NONE => () + | SOME line => loop inf + (* Programs that output will fail unless we eat their output *) + val () = loop (Unix.textInstreamOf proc) + in + OS.Process.isSuccess (Unix.reap proc) + end + fun shellOutput ss = let val proc = Unix.execute ("/bin/bash", ["-c", String.concat ss ^ " 2>&1"])