March 06, 2021
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?
March 07, 2021
On Saturday, 6 March 2021 at 21:20:30 UTC, kdevel wrote:
>
> ```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?

I probably missed that from the documentation and was trying to make it work with pipeProcess.


1 2 3
Next ›   Last »