Run child process with null stdin/stdout

Justin Whear via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Jun 18 13:00:43 PDT 2014


On Wed, 18 Jun 2014 19:37:58 +0000, David Nadlinger wrote:

> Hi all,
> 
> is there a platform independent way to do the equivalent of
> "some_program < /dev/null > /dev/null" using std.process?
> 
> I neither want to capture/print the standard output of the child process
> nor have anything available on its input.
> 
> Quite probably, I'm just missing something obvious…
> 
> Cheers,
> David

`spawnProcess`: The optional arguments stdin, stdout and stderr may be 
used to assign arbitrary std.stdio.File objects as the standard input, 
output and error streams, respectively, of the child process. The former 
must be opened for reading, while the latter two must be opened for 
writing.

For POSIX, seems like you could pass `File("/dev/null", "r")` for stdin 
and `File("/dev/null", "w")`.  On Windows I believe you can use `File
("nul")` for the same effect.


More information about the Digitalmars-d-learn mailing list