java waitfor() never returns when warnings occur
Posted: 2010-10-27T14:11:56-07:00
I've found that when I shell out from java to execute imageMagick convert.exe, it will never return a 'process complete' state to the java Process.waitfor() method whenever warnings occur.
For example, if I exec the command line:
I'll get:
Which are valid warnings for that particular file. The problem is that if I shell out of java with that same command it will just hang, even though the process has actually completed. I.e. it's as though convert.exe is still running (as far as java is concerned).
For what it's worth, my java looks like:
What I've discovered as a workaround is that by adding the -quiet switch the problem goes away. The process returns normally and everything works properly.
So I guess my question is - is this a bug? Frankly I'm more concerned about the java side than imageMagick, but I'm wondering what the process could be doing to cause this behavior, and whether there's a way to detect this?
Thanks in advance,
Tim
For example, if I exec the command line:
Code: Select all
"c:\Program Files\ImageMagick\convert.exe"
+matte -gravity Center -thumbnail 100x100 -density 72 -background white -extent 100x100
"C:\ingest\VRUpload\ag-obj-241-014-mas.tif"
"C:\ingest\thumbs\ag-obj-241-014-mas.jpg"
Code: Select all
convert.exe: C:\ingest\VRUpload\ag-obj-241-014-mas.tif: wrong data type 7 for "XMLPacket"; tag ignored. `TIFFReadDirectory' @ tiff.c
/TIFFWarnings/546.
convert.exe: C:\ingest\VRUpload\ag-obj-241-014-mas.tif: wrong data type 7 for "RichTIFFIPTC"; tag ignored. `TIFFReadDirectory' @ tif
f.c/TIFFWarnings/546.
convert.exe: C:\ingest\VRUpload\ag-obj-241-014-mas.tif: wrong data type 7 for "Photoshop"; tag ignored. `TIFFReadDirectory' @ tiff.c
/TIFFWarnings/546.
convert.exe: C:\ingest\VRUpload\ag-obj-241-014-mas.tif: unknown field with tag 37724 (0x935c) encountered. `TIFFReadDirectory' @ tif
f.c/TIFFWarnings/546.
For what it's worth, my java looks like:
Code: Select all
Process proc = null;
try
{
proc = Runtime.getRuntime().exec(command);
}
catch (IOException e)
{
throw new MediaToolsException("IOException while trying to execute: " + command + "\n"+e.getMessage());
}
while (true)
{
try
{
proc.waitFor(); // This line just hangs forever when those warnings occur.
break;
}
catch (java.lang.InterruptedException e)
{
throw new MediaToolsException("IngestUtils.exec: Process interrupted while trying to execute: " + command);
}
}
So I guess my question is - is this a bug? Frankly I'm more concerned about the java side than imageMagick, but I'm wondering what the process could be doing to cause this behavior, and whether there's a way to detect this?
Thanks in advance,
Tim