PluginProbe
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance / 3.2.5
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance v3.2.5
4.7.0 4.6.1 4.6.0 4.5.5 4.5.4 4.5.3 4.5.2 3.2.20 3.2.21 3.2.22 3.2.3 3.2.5 3.2.6 3.2.7 3.2.9 3.3.0 3.3.1 3.3.2 3.4.0 3.4.1 3.4.2 3.5.0 3.6.0 3.7.0 3.7.1 All 111 releases
wp-optimize / vendor / symfony / process / Tests / PipeStdinInStdoutStdErrStreamSelect.php

PipeStdinInStdoutStdErrStreamSelect.php in WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance 3.2.5, at vendor/symfony/process/Tests/PipeStdinInStdoutStdErrStreamSelect.php

73 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <[email protected]>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12 define('ERR_SELECT_FAILED', 1);
13 define('ERR_TIMEOUT', 2);
14 define('ERR_READ_FAILED', 3);
15 define('ERR_WRITE_FAILED', 4);
16
17 $read = [\STDIN];
18 $write = [\STDOUT, \STDERR];
19
20 stream_set_blocking(\STDIN, 0);
21 stream_set_blocking(\STDOUT, 0);
22 stream_set_blocking(\STDERR, 0);
23
24 $out = $err = '';
25 while ($read || $write) {
26 $r = $read;
27 $w = $write;
28 $e = null;
29 $n = stream_select($r, $w, $e, 5);
30
31 if (false === $n) {
32 exit(ERR_SELECT_FAILED);
33 } elseif ($n < 1) {
34 exit(ERR_TIMEOUT);
35 }
36
37 if (in_array(\STDOUT, $w) && strlen($out) > 0) {
38 $written = fwrite(\STDOUT, (string) $out, 32768);
39 if (false === $written) {
40 exit(ERR_WRITE_FAILED);
41 }
42 $out = (string) substr($out, $written);
43 }
44 if (null === $read && '' === $out) {
45 $write = array_diff($write, [\STDOUT]);
46 }
47
48 if (in_array(\STDERR, $w) && strlen($err) > 0) {
49 $written = fwrite(\STDERR, (string) $err, 32768);
50 if (false === $written) {
51 exit(ERR_WRITE_FAILED);
52 }
53 $err = (string) substr($err, $written);
54 }
55 if (null === $read && '' === $err) {
56 $write = array_diff($write, [\STDERR]);
57 }
58
59 if ($r) {
60 $str = fread(\STDIN, 32768);
61 if (false !== $str) {
62 $out .= $str;
63 $err .= $str;
64 }
65 if (false === $str || feof(\STDIN)) {
66 $read = null;
67 if (!feof(\STDIN)) {
68 exit(ERR_READ_FAILED);
69 }
70 }
71 }
72 }
73