D-Programming-Language/phobos — pull request #1928 by CyberShadow (2014-02-11 23:31:54+00:00)
Title: std.process: Add cwd parameter

Sometimes, it is useful to create a new process with a working directory different from the parent process.

This currently cannot be done in a nice way when using std.process:

- Setting the current directory just before calling the program is not thread-safe, since the current directory is shared across all threads.
- Although one can run the target program from a shell, and prefix the command with `"cd " ~ escapeShellFilename(cwd) ~ " && "`, this requires spawning a shell, which has a non-negligible performance cost on Windows.

This change adds yet another default parameter to the overloads of the 6 relevant functions. I don't see a better way without e.g. replacing the overloads with a function that takes a tuple and looking at each argument's types, similar to what `std.socket.getAddressInfo` does.