schveiguy at gmail.com
Thu Oct 11 13:09:33 UTC 2018
On 10/10/18 4:07 AM, Gorker wrote:
> On Wednesday, 10 October 2018 at 08:02:29 UTC, Kagamin wrote:
>> stderr buffer is full (it's about 8kb or so) and gcc waits when you
>> read from it.
> Thank you for your kind reply,
> How to just try to read from stdout (not blocking), and then try to read
> from stderr (not blocking)?
> I mean, how to check both pipes for data?
Probably you could use OS mechanisms like poll or select. Given your
usage of gcc, I'm assuming you are on some non-Windows system? Those
tools should be available.
Of course, it's hard to write a cross platform way to do this, so I
don't think std.process has ways to check if the pipe has data
asynchronously. Things are complicated by the fact that it wraps the
pipes in FILE * constructs, which means the file descriptor may not
reflect if data is available if it's already in the buffer.
I think the most reasonable way is to use multiple threads to process
the output. It may seem heavy-handed, but I don't know of a better way
given how std.process works.
> As an alternative, how to raise the 8kb limit?
You would have to use the OS mechanisms to do this (e.g.
strongly suggest not taking this route, I'm not sure how portable it is
to raise the buffer size after the pipe is in use. Plus, how much do you
raise the limit? What if you compile an even worse C program and get
100k of errors? ;)
More information about the Digitalmars-d-learn