digitalmars.D.learn - Run child process with null stdin/stdout
- David Nadlinger (8/8) Jun 18 2014 Hi all,
- Justin Whear (9/21) Jun 18 2014 `spawnProcess`: The optional arguments stdin, stdout and stderr may be
- David Nadlinger (7/12) Jun 18 2014 Implementing this myself is of course always an option, yes, but
- Steven Schveighoffer (8/17) Jun 19 2014 in
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
Jun 18 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.
Jun 18 2014
On Wednesday, 18 June 2014 at 20:00:43 UTC, Justin Whear wrote: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.Implementing this myself is of course always an option, yes, but I would have liked to avoid platform-dependent code. Hm, I just checked the source, and there doesn't seem to be a better option indeed… Thanks, David
Jun 18 2014
On Wed, 18 Jun 2014 16:15:40 -0400, David Nadlinger <code klickverbot.at==wrote:On Wednesday, 18 June 2014 at 20:00:43 UTC, Justin Whear wrote:inFor POSIX, seems like you could pass `File("/dev/null", "r")` for std=and `File("/dev/null", "w")`. On Windows I believe you can use `File=ld =("nul")` for the same effect.Implementing this myself is of course always an option, yes, but I wou=have liked to avoid platform-dependent code. Hm, I just checked the source, and there doesn't seem to be a better =option indeed=E2=80=A6I think a mechanism to open a null stream in an OS independent way would= = be a good addition to std.stdio (or perhaps std.process?) -Steve
Jun 19 2014