Opening temporary files for std.process.spawnProcess input/output
wobbles via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Feb 25 05:56:04 PST 2015
Hi,
Any reason why the following wont work?
void main(string[] args)
{
auto pidIn = File.tmpfile();
auto pidOut = File.tmpfile();
auto pid = spawnProcess(["ls", "./"], pidIn, pidOut,
std.stdio.stdout, null, Config.newEnv);
if(wait(pid) == 0)
writefln("%s", pidOut.readln());
}
The pidOut.readln() throws this exception:
object.Exception@/usr/include/dmd/phobos/std/stdio.d(1377):
Attempt to read from an unopened file.
I figured tmpfile() would be open for read/write by default?
Also, theres no way to pass in args to File.tmpfile() to make
them read/write.
Any ideas?
More information about the Digitalmars-d-learn
mailing list