- partially Revert "Merge pull request #4493 from schveiguy/fixcycles2"
- recreate processinit (and import it from std.process)
to call std.process shared ctor w/o creating a cycle
- keep it separate from phobosinit to not drag std.encoding
into any binary using std.process
v.idup returns null when called on an empty but non-null array. This is
undesirable because we want to differentiate between not-present and
empty-but-present.
The current Posix implementation of spawnProcess calls close on
every fd from 3 to the max fd count (as gathered by rlimit()).
Given that the process doesn't have that many descriptors open
in the *vast* majority of cases, this is quite pessimal.
Instead, use poll() to see which descriptors are actually open,
and close those.
Current document says:
```d
auto p = pipe();
p.writeEnd.writeln("Hello World");
assert (p.readEnd.readln().chomp() == "Hello World");
```
This means that buffer is yet to be flushed.
Therefore `p.readEnd.readln` can't recieve the input, for readln waits forever if the buffer is not flushed.
Then I fixed as follow:
```d
auto p = pipe();
p.writeEnd.writeln("Hello World");
p.writeEnd.flush();
assert (p.readEnd.readln().chomp() == "Hello World");
```
This diff: This diff makes it possible to specify your preferred shell for the various `*shell` functions in `std.process`. By default it uses the new `nativeShell` function. `nativeShell` to always returns the native system shell (see the "some history" section for why this is the default value). I chose to create `nativeShell` rather than changeing `userShell` because I think it is still valuable to have something like `userShell` around in Phobos.
The one part of this diff I'm not super thrilled by is the use of variadic arguments (easier to see than to explain); if you have a suggestion for something better I'd love to hear it :).
Note: The default shell is a breaking change for Windows, which probably *should have* been broken same as posix in the diffs listed in the history section below, but I suspect was overlooked. Find rationale behind making a breaking change at all here: https://issues.dlang.org/show_bug.cgi?id=15000.
Some history:
a524a3571b
and
f537cb50b5
Tried to move us from a world where we preferred the shell specified in the SHELL environment variable to a world where we always went with the native system shell, /bin/sh for posix. The former of those revisions was reverted in:
5b2b1fb594
Because the documentation was not updated to reflect the change.
Presently: we are in a state of schism, whereby `userShell` has behavior that does not align with what is actually used in `executeShell`, `pipeShell`, and `spawnShell`. This is something we *must* resolve.
Personal pain: This bit me when one of my scripts at work stopped working because it dependend on features that don't exist in `sh` (but do in `bash`, `zsh`, etc). It was really frustrating that there was no simple way to work around this and specify my preferred shell; it is, of course, possible to leverage the various `escape*` functions from `std.process` and `spawnProcess` to use whichever shell I prefer, but this seems like something warranting first class support. I was sad to not have something like this after a breaking change.