Код: Выделить всё
mkfifo /tmp/{a,b}
./a.out 0 & ./a.out 1 &
< /code>
Результаты < /p>
hello
bye
hello
bye
...
< /code>
На macos, однако, он просто задерживает. Кажется, что Ofstream :: flush () Код: Выделить всё
#include
#include
#include
using namespace std;
int main(int argc, char** argv)
{
ifstream in;
ofstream out;
string a;
assert(argc > 1);
if (atoi(argv[1]))
{
in.open("/tmp/a");
out.open("/tmp/b");
}
else
{
out.open("/tmp/a");
in.open("/tmp/b");
}
while (true)
{
assert(out.good());
assert(in.good());
if (atoi(argv[1]))
{
out a;
cout a;
cout
Подробнее здесь: [url]https://stackoverflow.com/questions/79641441/named-pipes-fifo-stalling-on-macos-with-c[/url]
Мобильная версия