On Saturday, 6 March 2021 at 01:53:15 UTC, Jesse Phillips wrote:
[...]
I think this post is going to answer your need.

https://dev.to/jessekphillips/piping-process-output-1cai

I haven't read all the replies, so maybe you have it working and this will benefit someone else.

If I understand your code correctly you have a program "reverse" writing output to another program "check". I am wondering why you have two threads shoveling data between pipes. In the example below data are read from stdin by the first process and is piped to another one which is finally piped
into the program and copied into a string appender.

```pipechain.d
import std.stdio;
import std.process;
import std.conv;
import std.array;
import std.range;
import std.algorithm;

int main (string [] args)
{
   auto p = pipe ();
   auto proc1 = spawnProcess (["cat"], stdin, p.writeEnd);
   auto q = pipe ();
   auto proc2 = spawnProcess (["cat"], p.readEnd, q.writeEnd);
   auto os = appender!string;
   q.readEnd.byChunk (4096).copy (os);
   auto res2 = wait (proc2);
   auto res1 = wait (proc1);
   stderr.writeln ("res1 = ", res1, ", res2 = ", res2);
   write (os[]);
   stderr.writeln ("fin");
   return 0;
}
```

AFAICS this is immune to SIGPIPE. Do I miss anything?
              • Re:... Danny Arends via Digitalmars-d-learn
              • Re:... frame via Digitalmars-d-learn
              • Re:... Danny Arends via Digitalmars-d-learn
              • Re:... Imperatorn via Digitalmars-d-learn
              • Re:... Imperatorn via Digitalmars-d-learn
              • Re:... Danny Arends via Digitalmars-d-learn
              • Re:... kdevel via Digitalmars-d-learn
              • Re:... Danny Arends via Digitalmars-d-learn
            • Re: How... Steven Schveighoffer via Digitalmars-d-learn
  • Re: How to get output of pipe... Jesse Phillips via Digitalmars-d-learn
    • Re: How to get output of... kdevel via Digitalmars-d-learn

Reply via email to