I’ve tried to write a set of functions that redirect both STDOUT and/or STDERR (capture_stderr, capture_stdout, capture_console), and return with the data as a string (we use this for testing purposes).
I had originally used readavailable
, which seemed to work, except that it blocks if there is nothing available.
Then I tried to modify it to check nb_available
, to see if it would block, however, even if readavailable has something to return, it is always returning 0.
Has anybody else run into this problem? (bug maybe?)
I would have thought that nb_availabile would return non-zero, if readavailable had something to return without waiting, but that is not the case.