Opening temporary files for std.process.spawnProcess input/output
Tobias Pankrath via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Feb 25 06:23:21 PST 2015
On Wednesday, 25 February 2015 at 13:56:06 UTC, wobbles wrote:
> 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?
maybe only for writing:
http://www.cplusplus.com/reference/cstdio/tmpfile/
More information about the Digitalmars-d-learn
mailing list