This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: kawa shell concept



On Feb 7, 2012, at 4:19 PM, Helmut Eller wrote:


* Per Bothner [2012-02-07 19:18] writes:

Pipe

(run in: (run "command1") "command2")

How's this implemented in Java? Is there even a JDK API to create real
pipes?

The default (and initial) implementation would just use a helper thread.
It reads from the output stream of command1, and writes to the input
stream of command2. Do you know of any problems (like risk of deadlock)
doing it this way?

No; it just sounds inefficient.

It wouldn't be that hard to call through to pipe(2), especially with JNA.
The tricky part is that then we'd have to have a way to get the file
descriptor ints used by pipe() to be used by the InputStream/ OutputStream
of the child Process with calls to read(2) and write(2). That seems like
it would imply a custom InputStream subclass, which would imply a custom
Process subclass to return our special InputStream, which would imply not
using the Process subtype returned by Runtime.exec() or ProcessBuilder.start().
So, we'd probably have to use JNI to call fork/exec or pthread_spawn().
Doesn't really seem worth it.


--
Jamison Hope
The PTR Group
www.theptrgroup.com




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]