GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fix #309 - Use stream_select instead of non-blocking STDIN · phpmyadmin/sql-parser@5419487

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src/Utils
    • CLI.php
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/Utils/CLI.php‎

Copy file name to clipboardExpand all lines: src/Utils/CLI.php
+16-5Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -233,11 +233,22 @@ public function runTokenize()
233233
return 1;
234234
}
235235

236-
public function readStdin() {
237-
stream_set_blocking(STDIN, false);
238-
$stdin = stream_get_contents(STDIN);
239-
// restore-default block-mode setting
240-
stream_set_blocking(STDIN, true);
236+
public function readStdin()
237+
{
238+
$read = [STDIN];
239+
$write = [];
240+
$except = [];
241+
242+
// Assume there's nothing to be read from STDIN.
243+
$stdin = null;
244+
245+
// Try to read from STDIN. Wait 0.2 second before timing out.
246+
$result = stream_select($read, $write, $except, 0, 2000);
247+
248+
if ($result > 0) {
249+
$stdin = stream_get_contents(STDIN);
250+
}
251+
241252
return $stdin;
242253
}
243254
}

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.