Page MenuHomePhabricator

D21317.id50777.diff
No OneTemporary

D21317.id50777.diff

diff --git a/src/toolset/ArcanistPrompt.php b/src/toolset/ArcanistPrompt.php
--- a/src/toolset/ArcanistPrompt.php
+++ b/src/toolset/ArcanistPrompt.php
@@ -113,12 +113,32 @@
$write = array();
$except = array();
- $ok = stream_select($read, $write, $except, 1);
+ $ok = @stream_select($read, $write, $except, 1);
if ($ok === false) {
- throw new Exception(pht('stream_select() failed!'));
+ // NOTE: We may be interrupted by a system call, particularly if
+ // the window is resized while a prompt is shown and the terminal
+ // sends SIGWINCH.
+
+ // If we are, just continue below and try to read from stdin. If
+ // we were interrupted, we should read nothing and continue
+ // normally. If the pipe is broken, the read should fail.
+ }
+
+ $response = '';
+ while (true) {
+ $bytes = fread($stdin, 8192);
+ if ($bytes === false) {
+ throw new Exception(
+ pht('fread() from stdin failed with an error.'));
+ }
+
+ if (!strlen($bytes)) {
+ break;
+ }
+
+ $response .= $bytes;
}
- $response = fgets($stdin);
if (!strlen($response)) {
continue;
}

File Metadata

Mime Type
text/plain
Expires
May 14 2024, 8:45 AM (6 w, 2 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6295030
Default Alt Text
D21317.id50777.diff (1 KB)

Event Timeline