View source code
Display the source code in std/process.d from which this
page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a
Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
local clone.
Enum std.process.Config
Flags that control the behaviour of process creation functions in this
module. Most flags only apply to spawnProcess
and
spawnShell
.
enum Config
: int { ... }
Use bitwise OR to combine flags.
Enum members
Name | Description |
---|---|
detached
|
Spawn process in detached state. This removes the need in calling
wait to clean up the process resources.
Note |
inheritFDs
|
On POSIX, open file descriptors
are by default inherited by the child process. As this may lead
to subtle bugs when pipes or multiple threads are involved,
spawnProcess ensures that all file descriptors except the
ones that correspond to standard input/output/error are closed
in the child process when it starts. Use inheritFDs to prevent
this.
On Windows, this option has no effect, and any handles which have been explicitly marked as inheritable will always be inherited by the child process. |
newEnv
|
By default, the child process inherits the parent's environment,
and any environment variables passed to spawnProcess will
be added to it. If this flag is set, the only variables in the
child process' environment will be those given to spawnProcess.
|
retainStderr
|
Unless the child process inherits the standard input/output/error
streams of its parent, one almost always wants the streams closed
in the parent when spawnProcess returns. Therefore, by
default, this is done. If this is not desirable, pass any of these
options to spawnProcess.
|
retainStdin
|
Unless the child process inherits the standard input/output/error
streams of its parent, one almost always wants the streams closed
in the parent when spawnProcess returns. Therefore, by
default, this is done. If this is not desirable, pass any of these
options to spawnProcess.
|
retainStdout
|
Unless the child process inherits the standard input/output/error
streams of its parent, one almost always wants the streams closed
in the parent when spawnProcess returns. Therefore, by
default, this is done. If this is not desirable, pass any of these
options to spawnProcess.
|
stderrPassThrough
|
By default, the execute and executeShell functions
will capture child processes' both stdout and stderr. This can be
undesirable if the standard output is to be processed or otherwise
used by the invoking program, as execute 's result would then
contain a mix of output and warning/error messages.
Specify this flag when calling This flag has no effect on |
suppressConsole
|
On Windows, if the child process is a console application, this
flag will prevent the creation of a console window. Otherwise,
it will be ignored. On POSIX, suppressConsole has no effect.
|
Example
auto logFile = File("myapp_error.log", "w");
// Start program, suppressing the console window (Windows only),
// redirect its error stream to logFile, and leave logFile open
// in the parent process as well.
auto pid = spawnProcess("myapp", stdin, stdout, logFile,
Config .retainStderr | Config .suppressConsole);
scope(exit)
{
auto exitCode = wait(pid);
logFile .writeln("myapp exited with code ", exitCode);
logFile .close();
}
Authors
Lars Tandle Kyllingstad, Steven Schveighoffer, Vladimir Panteleev
License
Copyright © 1999-2018 by the D Language Foundation | Page generated by ddox.