Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem invoking Runtime.exec with ImageMagick



Ralph Scheuer wrote:

>Thanks for your reply. However, my point is that this method / snippet
>works fine as is as long as I use non-EPS files, i.e. as long as
>ImageMagick's identify does not try to invoke gs.

Understood.  Consider them as bug-reports to fix after you get the
fundamental issue resolved.


>That's right. However, I'm really getting _nothing_ back, absolutely nada.

There are two possible interpretations of _nothing_:
  1) the Process never exits and never writes anything.
  2) the Process exits but never writes anything.

In the first case, your code will hang indefinitely as the read() is
blocked on a pipe that never has any data.  In the second case, your code
will get an EOF as soon as the child Process exits.

My guess is that the second case is what's happening, but you didn't
explain the full extent of nothingness that isn't happening, so it's only a
guess.

The reason it matters is that if the Process terminates you can call its
exitValue() to find out whether it thinks it succeeded or not.  Zero is
success, non-zero is an error.  See the API docs for exitValue() for
details.

As others have already said, I also strongly recommend reading the
error-stream.  It could well contain a message that explains why 'identify'
didn't work.  For example, if 'identify' tried to run the 'gs' command but
couldn't find it, an error message may show that, so you could then confirm
whether the PATH env-var was sufficient (e.g. exec the 'printenv' command).
Or if 'gs' wants a tty for output rather than a pipe, that might also
appear on the stderr stream.

You should spin off a separate thread to drain and collect the
error-stream, otherwise you might cause a deadlock.  See also:
  <http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps_p.html>

The StreamGobbler class provided there still exhibits the problem of
assuming the default text-encoding.  It's probably not significant yet, so
it should work well enough as given for now.  Besides, googling for
StreamGobbler shows a zillion hits, so you could probably find one sooner
than writing one yourself.


By not looking at exitValue() and any error-stream output, all anyone can
do is guess what might be going wrong.  As my recent posts have shown, I
can guess at things till the cows come home or pigs sprout wings, but all
my guesses can still be completely wrong.

It's much better to look at the evidence Process gives you.

  -- GG


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.