<?php
function try_select($fp): int {
    $read = [$fp];
    $write = null;
    $except = null;
    $n = @stream_select($read, $write, $except, 0, 50000);
    if ($n === false) {
        return -1;
    }
    return (int) $n;
}

echo try_select(fopen('php://temp', 'r')), PHP_EOL;
