# Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license # found at http://www.opensource.org/licenses/mit-license.html ................ I haven't thought through what E-on-CL's general external process interface should be. For now, I'm arranging for the 'makeCommand' interface and some programs of mine to work. ' Basic test, and exit status. ? def spawn := # value: XXX assumption of particular paths in this test ? interp.waitAtTop(def process := spawn <- (, [])) ? interp.waitAtTop(def info := [process <- getOptStdin(), process <- getOptStdout()]) ? info # value: [null, null] ? [process, def status := process <- getExitValue()] # value: [, ] ? interp.waitAtTop(status) ? status # value: 0 XXX an early version of this test script had the exit value as [0] -- why? something to do with signal exit values? Exit status again. ? interp.waitAtTop(def status := spawn <- (, []) <- getExitValue()) ? status # value: 1 Streams. ? def ascii := ["US-ASCII"]; null ? interp.waitAtTop(def output := spawn <- ( > , > ["-n", "ding"], > ["stdout" => "PIPE"], > ) <- getOptStdout()) ? interp.waitAtTop(output) ? def outText := ascii.decode(output, [].asMap()); null ? interp.waitAtTop(def r := EIO.takeAll(outText)) ? r # value: "ding" ? def process := spawn <- ( > , > [], > ["stdin" => "PIPE", > "stdout" => "PIPE"]) # value: ? interp.waitAtTop(def input := process <- getOptStdin()) ? interp.waitAtTop(def output := process <- getOptStdout()) ? input.reserve() <- resolve([3, 1, 4, 1, 5]); input.reserve() <- resolve(null); null ? interp.waitAtTop(def r := EIO.takeAll(output)) ? r # value: [3, 1, 4, 1, 5] ? interp.waitAtTop(def output := spawn <- ( > , > ["ding"], > ["stderr" => "PIPE"], > ) <- getOptStderr()) ? interp.waitAtTop(output) ? def outText := ascii.decode(output, [].asMap()); null ? interp.waitAtTop(def r := EIO.takeAll(outText)) ? r # value: "cat: ding: No such file or directory # " XXX TODO: - encoding of command arguments - response to bad file, bad arguments - process exit status when killed - all std* handling modes - environment control - PATH search - killing process