This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Linux / UNIX and the fly likes sh shell on linux with a loop that calls java hangs Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "sh shell on linux with a loop that calls java hangs" Watch "sh shell on linux with a loop that calls java hangs" New topic

sh shell on linux with a loop that calls java hangs

Kathy King

Joined: Jul 25, 2012
Posts: 4
I have an sh shell running on linux. It has a loop and each loop instantiates another sh that instantiates a java class. This works great on a Solaris box (we are transitioning) but hangs on each iteration of the loop on a linux box. Here is the loop...


for JRNL in `$DBRUNSCRIPT $FLAG -jm -work -q -j bmj /highwire-dev/journals/mstr/maint/db/find_portal_jobs.sql` #this command returns proper values
techo "portaluserjobs: Starting $JRNL"
/mstr/userjobs/scripts/userjobs -n portalRole -j $JRNL


/mstr/userjobs/scripts/userjobs does...

/mstr/system/ $JAVA_ARGS org.highwire.mstr.client.misc.UserJobQueueClient $*

Again, this works fine on Solaris. We have made no changes to the shells. Each iteration hangs...then if I go to where the script is running and Ctrl-C it will go on to the next iteration. Not sure if this is a linux issue or not. Covering all bases as investigation thus far has not produced a solution.
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24195

Well, nothing jumps out at me, but let's dig in a little more.

First, maybe something in ? What does that do?

Second, what version of Java are you running -- the real Oracle one, or the IcedTea one, or maybe even the gcj one? They might all act differently.

Third, is the Java program a command-line or GUI program? Just wondering if there's a reason for the JVM not to exit.

[Jess in Action][AskingGoodQuestions]
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17257

Yes, there are small, but annoying differences between Java on Linux and Java on Solaris. There are not-so-small differences between the Linux bash shell and the Solaris shell. Circa 2005, the Solaris 8 shell more closely resembled the 1995 Linux bash than it did the 2005 Linux bash. I never really paid attention to what - if any - improvements had been made for Solaris 10 or 11. I did find it very annoying that the distributed Tomcat for Solaris 10 was Tomcat 4, even though Tomcat 4 had passed End of Life and was no longer supported by Apache,

Check and see if hitting "Enter" will advance your script. It's possible that there's a hangup looking for data from stdin (Ctrl-D is a good bet as well). Otherwise there appears to be an issue in your Java app that prevents it from terminating.

An IDE is no substitute for an Intelligent Developer.
Kathy King

Joined: Jul 25, 2012
Posts: 4
Hi, So, you were all on the right track I just didn't see the responses before we solved the issue. (I should change my frequency if I'm going to be posting). So ends up the shells were fine. We are also going from Java 1.42 to 6, and from Weblogic/Apache/Jserv to Tomcat/Apache. So ends up threading is handled a bit differently since we are no longer using the same type of JVM. So adding an additional poll for life was necessary. Now everything works as expected. As to whether the code is still doing the proper tasks is the next to be scrutinized.

Thanks to all who replied!
subject: sh shell on linux with a loop that calls java hangs
jQuery in Action, 3rd edition