When I run this code, the boost::process::std_out > "myfifo"
line doesn't return because it's waiting on the open
call to return, which it doesn't because "myfifo" is a fifo. Is this a bug?
#include <boost/process.hpp>
int main(int, char**)
{
mkfifo("myfifo", 0600);
auto x = boost::process::std_out > "myfifo";
return 0;
}
That's interesting, because the behaviour of the code you use is undefined.
The parameter keywords are, effectively, a "DSL" that builds extension properties to be used by the executor.
In spite of the fact that the implementation details of the template expressions is unspecified, one would expect lone parameter objects to have no observable side effects.
That makes your observed hang remarkable. I think it's a weak design when the mere composition of the argument expressions has side-effects (even on destruction, by the way). It would be much better if the actions would only run at the time of process execution, IMHO.
You might report this to the library developers (though they'll probably say "don't do that" and mark it as "by design").
In fact bp::std_out > "filename"
, does not try to open the fifo. It tries to create the file (since it's write-only, and you intend to write data to it).
If you want to write to a fifo, you will want to use the pipe
or async_pipe
facilities.