1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-21 22:32:41 +01:00

On Windows, don't try to set "stdin" nonblocking, as it does not work

Summary:
See <https://discourse.phabricator-community.org/t/arc-land-fail-unable-to-set-stdin-nonblocking/4006/>.

See also <https://bugs.php.net/bug.php?id=34972>.

Note that you can't ^C during a prompt (or at any other time) in Windows currently, see T13549.

Test Plan: On Windows, hit a prompt in "arc land", then answered it successfully.

Differential Revision: https://secure.phabricator.com/D21358
This commit is contained in:
epriestley 2020-06-12 14:16:36 -07:00
parent 1e09a0ee7e
commit 33dfa859d8

View file

@ -86,19 +86,23 @@ final class ArcanistPrompt
throw $ex;
}
// NOTE: We're making stdin nonblocking so that we can respond to signals
// immediately. If we don't, and you ^C during a prompt, the program does
// not handle the signal until fgets() returns.
$stdin = fopen('php://stdin', 'r');
if (!$stdin) {
throw new Exception(pht('Failed to open stdin for reading.'));
}
// NOTE: We're making stdin nonblocking so that we can respond to signals
// immediately. If we don't, and you ^C during a prompt, the program does
// not handle the signal until fgets() returns.
// On Windows, we skip this because stdin can not be made nonblocking.
if (!phutil_is_windows()) {
$ok = stream_set_blocking($stdin, false);
if (!$ok) {
throw new Exception(pht('Unable to set stdin nonblocking.'));
}
}
echo "\n";
@ -117,9 +121,12 @@ final class ArcanistPrompt
$query,
$options);
while (true) {
$is_saved = false;
if (phutil_is_windows()) {
$response = fgets($stdin);
} else {
while (true) {
$read = array($stdin);
$write = array();
$except = array();
@ -156,6 +163,7 @@ final class ArcanistPrompt
break;
}
}
$response = trim($response);
if (!strlen($response)) {