Author Login
Post Reply
gregsmit wrote:
>
> Hi,
>
> This is less of a question about Ant, than it is a question "How do they do
> that??"
>
> Ant has the ability to spawn a new process, where all of the output of the
> new process goes in the bit bucket, and the original Java process can go
> away. The spawned process stays running.
>
> The reason I'm wondering how this works is -- I've always had problems
> before with Runtime.exec() that if I didn't grab the new process' output
> streams and consume everything off of them, then the exec'ed process would
> eventually block on its stdout and stderr.
>
> But Ant seems to have found away to redirect the exec'ed process' stdout and
> stderr, so that even when the parent java process goes away, the child
> doesn't get blocked. Without native / JNI code.
>
> How? Maybe its something new (at least newer than the last time I used
> Runtime.exec) in Java 1.5+?
>
> I tried to follow the code, but still didn't quite understand. It looked
> like it created threads to consume the output, but those would go away when
> the ant/java process ends.
For spawning ant unhooks all input and output altogether. Close the
channels and let the recipient work it out for itself. No fancy java1.5+
isms; everything works the same on java1.4.
The moment you try and catch any of the output, spawned code doesnt
outlive your process.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)