0) { $written = fwrite(STDOUT, (binary) $out, 32768); if (false === $written) { die(ERR_WRITE_FAILED); } $out = (binary) substr($out, $written); } if (null === $read && strlen($out) < 1) { $write = array_diff($write, array(STDOUT)); } if (in_array(STDERR, $w) && strlen($err) > 0) { $written = fwrite(STDERR, (binary) $err, 32768); if (false === $written) { die(ERR_WRITE_FAILED); } $err = (binary) substr($err, $written); } if (null === $read && strlen($err) < 1) { $write = array_diff($write, array(STDERR)); } if ($r) { $str = fread(STDIN, 32768); if (false !== $str) { $out .= $str; $err .= $str; } if (false === $str || feof(STDIN)) { $read = null; if (!feof(STDIN)) { die(ERR_READ_FAILED); } } } }