Non-blocking reads of a fifo (named pipe)?

Anonymouse asdf at asdf.net
Mon Dec 3 23:32:10 UTC 2018


I have a fifo that I want to read lines from, but everything is 
blocking.

execute([ "mkfifo", filename ]);
File fifo = File(filename, "r");  // blocks already
immutable input = fifo.readln();  // blocks
foreach (line; fifo.byLineCopy) { /* blocks */ }

How can I go about doing this to get non-blocking reads? Or 
perhaps a way to test whether there is text waiting in the fifo? 
File.eof is not it.

if (fifo.hasData)
{
     immutable stuff = fifo.readln();
     // ...
}


More information about the Digitalmars-d-learn mailing list