ExternalProcess

UNSTABLE, NOT FULLY IMPLEMENTED. DO NOT USE YET.

You might use this like:

auto proc = new ExternalProcess();
auto stdoutStream = new ReadableStream();

// to use a stream you can make one and have a task consume it
runTask({
	while(!stdoutStream.isClosed) {
		auto line = stdoutStream.get!string(e => e == '\n');
	}
});

// then make the process feed into the stream
proc.onStdoutAvailable = (got) {
	stdoutStream.feedData(got); // send it to the stream for processing
	stdout.rawWrite(got); // forward it through to our own thing
	// could also append it to a buffer to return it on complete
};
proc.start();

Please note that this does not currently and I have no plans as of this writing to add support for any kind of direct file descriptor passing. It always pipes them back to the parent for processing. If you don't want this, call the lower level functions yourself; the reason this class is here is to aid integration in the arsd.core event loop. Of course, I might change my mind on this.

class ExternalProcess {
int stdoutBufferSize;
int stderrBufferSize;
version(Posix)
void delegate() beforeExec;
bool completed;
int status;
void delegate(ubyte[] got) onStdoutAvailable;
void delegate(ubyte[] got) onStderrAvailable;
void delegate(int code) onTermination;
}

Constructors

this
this(string program, string commandLine)

This is the native version for Windows.

this
this(FilePath program, string[] args)

This is the native version for Posix.

Members

Functions

writeToStdin
void writeToStdin(void[] data)

If blocking, it will block the current task until the write succeeds.

Bugs

Not implemented at all on Windows yet.

Meta