On Friday, 29 January 2021 at 03:49:38 UTC, Ali Çehreli wrote:
On 1/28/21 3:45 PM, Anthony wrote:

> void end(AccumulatorPipe acc) {
>      auto pids = acc.pids ~ P.spawnShell("cat", acc.stdout);
>
>      foreach (pid; pids) {
>          P.wait(pid);
>      }
> }
> ```
>
>
> So now I can do something like:
> ```
> run("find source -name '*.d'")
>          .pipe("entr ./make.d tests")
>          .end(),

Cool but there should be one improvement because I don't think end() is guaranteed to be executed in that code, which may leave zombie processes around. From 'man waitpid':

"A child that terminates, but has not been waited for becomes a "zombie".

Which is relayed to std.process documentation as "to avoid child processes becoming "zombies"".

Ali

I take it you're referring to missing scope guards like in your code
`scope (exit) wait(lsPid);`

Yeah, that is a tricky one. I can't think of a way to have a nice interface that also closes the pids on exit since scope guards are handled on function exit in this case.

Perhaps thats just the nature of the problem though.

I'll take a look at what scriptlike does https://github.com/Abscissa/scriptlike#script-style-shell-commands

Reply via email to