[Issue 18309] New: std.process.pipeProcess should warn if the buffer is full
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Jan 26 22:19:55 UTC 2018
https://issues.dlang.org/show_bug.cgi?id=18309
Issue ID: 18309
Summary: std.process.pipeProcess should warn if the buffer is
full
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: major
Priority: P1
Component: phobos
Assignee: nobody at puremagic.com
Reporter: greensunny12 at gmail.com
This program never terminates:
```
void main(string[] args)
{
import std.process, std.stdio;
"starting".writeln;
auto pipes = pipeProcess(["seq", "13000"], Redirect.stdout); // set me to
12k to work
while(true) {
auto res = tryWait(pipes.pid);
if (res.terminated) break;
}
foreach (c; pipes.stdout.byChunk(100)) {
writeln(cast(string) c);
break;
}
"finished".writeln;
}
```
This is due to pipe's buffer (PIPE_BUF) being exceeded.
http://man7.org/linux/man-pages/man2/pipe.2.html
Of course, the solution is to read from the pipe in the loop, but I feel like
this is still something that's very easy to run into.
Not sure whether that's something that can/should be done by the library code,
or it should simply be documented better.
--
More information about the Digitalmars-d-bugs
mailing list