1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-12-28 08:20:56 +01:00
No description
Find a file
epriestley 0140a0e990 [Wilds] On Windows: always use stdout/stderr files and always "bypass_shell"
Summary:
Ref T13209. I'll walk through this a bit inline, but two major ideas here:

---

First, always use `bypass_shell` when calling `proc_open()`. The effect of this parameter is to use a "raw" `CreateProcessW()` Windows API call to spawn the subprocess instead of wrapping it in `cmd.exe /c ...`, which is roughly equivalent to `sh -c`.

The major advantage of adding `cmd.exe /c ...` is that you can use shell features like `> outfile.txt`.

The major disadvantage of adding `cmd.exe /c ...` is that `cmd.exe` is a terrible shell and escaping becomes absurdly complicated and position-dependent. It does not appear to be possible to escape some characters, like "\n", in argument lists passed through `cmd.exe`. It is unclear if we can safely escape environmental variables ("%APPDATA%"). PHP gives up on this and Python defaults to a `bypass_shell` equivalent with warnings about how using `shell=True` is dangerous, although they appear to understate the danger.

Since we don't currently rely on any shell features, don't plan to rely on shell features, and making program behavior generally sane should be easier without needing to fight against `cmd.exe`, always bypass it for now. We may later find that we need it in some cases (e.g. remote execution, or `arc alias` shell commands, or whatever else). If so, we can support it at that time with an elective mode on `CommandString`, but bypassing it seems to clearly be the far saner default.

---

Second, Windows doesn't have nonblocking pipes so if you try to read output from a subprocess you block until it exits. Most of the time that's not great but ends up working out okay, but when it's not fine you likely just deadlocked and hung and that's the end of you.

We can avoid this by using files instead of pipes. We've supported this mode since D11688, but never used it in the upstream. Ostensibly, it works. Make it the only mode, then rearrange it a bit so that resource management is a little tighter (for example, previously we could try to use `$pipes[0]` even after `proc_open()` failed, which meant that `$pipes` would not be populated).

It appears to //actually// work, in the sense that all the tests pass, which is promising.

Test Plan: With further changes, no tests fail on Windows, which is at least promising.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13209

Differential Revision: https://secure.phabricator.com/D19727
2018-10-03 07:48:45 -07:00
bin [Wilds] Rewrite "arc" entrypoints for toolsets 2018-09-21 15:55:08 -07:00
externals [Wilds] Remove include_path mangling and drop support for "externals/includes" 2018-09-21 16:44:11 -07:00
resources [Wilds] Update "arc shell-complete" for toolsets 2018-09-25 16:02:13 -07:00
scripts [Wilds] Make more test cases (mostly related to the phutil -> arcanist move) pass 2018-10-01 16:36:12 -07:00
src [Wilds] On Windows: always use stdout/stderr files and always "bypass_shell" 2018-10-03 07:48:45 -07:00
support [Wilds] Make more test cases (mostly related to the phutil -> arcanist move) pass 2018-10-01 16:36:12 -07:00
.arcconfig Set "history.immutable" to "false" explicitly in .arcconfig in Arcanist 2016-08-03 08:13:09 -07:00
.arclint Fold ArcanistPhutilXHPASTLinter into ArcanistXHPASTLinter 2015-11-13 07:08:40 +11:00
.arcunit Rough version of configuration driven unit test engine 2015-08-11 06:54:16 +10:00
.editorconfig Test XHPAST linter rules in isolation 2015-11-19 08:57:23 +11:00
.gitignore [Wilds] Update "arc shell-complete" for toolsets 2018-09-25 16:02:13 -07:00
LICENSE Fix text lint issues 2015-04-07 18:09:27 +10:00
NOTICE Remove duplicate newline 2014-07-17 08:25:22 +10:00
README.md Move README to Markdown 2015-04-13 13:01:16 -07:00

Arcanist is the command-line tool for Phabricator. It allows you to interact with Phabricator installs to send code for review, download patches, transfer files, view status, make API calls, and various other things. You can read more in the User Guide

For more information about Phabricator, see http://phabricator.org/.

LICENSE

Arcanist is released under the Apache 2.0 license except as otherwise noted.