Do not block when nothing is passed via stdin.

This commit is contained in:
Andreas Fischer 2014-04-15 18:04:54 +02:00
parent d2c7a8ee59
commit 854dd8fa7c
1 changed files with 4 additions and 1 deletions

View File

@ -123,8 +123,11 @@ class ConvertType extends Command {
return;
}
// Read from stdin
// Read from stdin. stream_set_blocking is used to prevent blocking
// when nothing is passed via stdin.
stream_set_blocking(STDIN, 0);
$password = file_get_contents('php://stdin');
stream_set_blocking(STDIN, 1);
if (trim($password) !== '') {
$input->setOption('password', $password);
return;