Are Groovy pipes real UNIX pipes?

Viewed 3809

I just started today looking into Groovy. I consider using it to replace some of my more complex bash scripts.

One of its very interesting concepts for me is the possibility to use pipes easily:

proc1 = 'ls'.execute()
proc2 = 'tr -d o'.execute()
proc3 = 'tr -d e'.execute()
proc4 = 'tr -d i'.execute()
proc1 | proc2 | proc3 | proc4
proc4.waitFor()

That's amazing. But my question is: Does this use real UNIX pipes (when run e.g. on Linux), or is this just a simulation with Java streams? (And if so, is it much slower/more inefficient?)

3 Answers

Groovy cannot use Unix pipes, because Unix pipes must be setup before the child processes are started. But your example first starts all process and connects them with pipes later.

Also Groovy would have to call some filehandle manipulation system calls (dup, dup2) which are not available in the JVM without using some additional native library.

Related