File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Threads and Synchronization and the fly likes UNIXProcess.forkandExec() hang? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "UNIXProcess.forkandExec() hang?" Watch "UNIXProcess.forkandExec() hang?" New topic
Author

UNIXProcess.forkandExec() hang?

R Deepak Ram
Greenhorn

Joined: Aug 18, 2004
Posts: 2
Greetings!

I'm using tomcat 3.2 with apache 1.3.x on JDK 1.3.1_03 on RedHat Linux 7.2.

One of my servlets calls an external program using the exec() call.

Sometimes, (noticed no pattern), exec() locks up and the external program does not get called. After this happens, everything else trying to do an exec locks up at the same point too!

Nothing is synchronized, and SingleThreadModel is not used for the servlet.

Here is a thread dump...

"Thread-183" prio=1 tid=0x81f2960 nid=0x2006 waiting on monitor [0xabbfd000..0xabbff8b0]
at java.lang.Object.wait(Native Method)
- waiting on <43b53fe0> (a java.lang.Object)
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.<init>(UNIXProcess.java:139)
at java.lang.Runtime.execInternal(Native Method)
at java.lang.Runtime.exec(Runtime.java:546)
at java.lang.Runtime.exec(Runtime.java:413)
at java.lang.Runtime.exec(Runtime.java:356)
at java.lang.Runtime.exec(Runtime.java:320)
at CygNet.Html.p2ms.reports.ReportBuilder.drawGraph(ReportBuilder.java:86)
at CygNet.Html.p2ms.reports.ReportGenerator.generateReport(ReportGenerator.java:644)
at CygNet.Html.Reports.LinkUtilServlet.generateUtilReport(LinkUtilServlet.java:119)
at CygNet.Html.Reports.LinkUtilServlet.service(LinkUtilServlet.java:77)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
at org.apache.tomcat.core.Handler.service(Handler.java:286)
at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:797)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
at org.apache.tomcat.service.connector.Ajp13ConnectionHandler.processConnection(Ajp13ConnectionHandler.java:160)
at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
at java.lang.Thread.run(Thread.java:479)


All the locked processes have a

- waiting on <43b53fe0> (a java.lang.Object)

Any hints?

Thanks
R Deepak Ram
Greenhorn

Joined: Aug 18, 2004
Posts: 2
Also,

"process forker" daemon prio=1 tid=0x682093e8 nid=0x5149 waiting on monitor [0xbe1ff000..0xbe1ff8b0]
at java.lang.Object.wait(Native Method)
- waiting on <43b53fe0> (a java.lang.Object)
at java.lang.UNIXProcessForker.run(Native Method)
at java.lang.Thread.run(Thread.java:479)
Ulas Ergin
Ranch Hand

Joined: Oct 10, 2002
Posts: 77
try exhausintg our and err streams of the process via seperate threads,

the OS has some buffer for these and if you don't consume them you may got in trouble

hope this helps
Mr. C Lamont Gilbert
Ranch Hand

Joined: Oct 05, 2001
Posts: 1170

Originally posted by Ulas Ergin:
try exhausintg our and err streams of the process via seperate threads,

the OS has some buffer for these and if you don't consume them you may got in trouble

hope this helps


'out' and 'err' streams he means.
m qasim
Greenhorn

Joined: Sep 07, 2004
Posts: 5
also close the error, output and input streams and call process.waitFor(),process.destroy()
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: UNIXProcess.forkandExec() hang?