• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

exitValue returns inconsistent values.

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am invoking a executable c file which accepts a single integer parameter through Runtime.exec method. The C code returns the same value back to Java.
When i try to capture this return value by printing the return code of exitValue() method, i am getting inconsistent values.

Return.java :

The C code : /tmp/test.c


When i iterate the call through a count, i am getting the following inconsistent values :

The return value of the child process is : 13
The return value of the waitFor method is : 13
Given value is : /tmp/test_return 14
The return value of the child process is : 14
The return value of the waitFor method is : 14
Given value is : /tmp/test_return 15
The return value of the child process is : 15
The return value of the waitFor method is : 15
Given value is : /tmp/test_return 16
The return value of the child process is : 0
The return value of the waitFor method is : 0
Given value is : /tmp/test_return 17
The return value of the child process is : 0
The return value of the waitFor method is : 0
Given value is : /tmp/test_return 18
The return value of the child process is : 18
The return value of the waitFor method is : 18
Given value is : /tmp/test_return 19
The return value of the child process is : 19
The return value of the waitFor method is : 19
Given value is : /tmp/test_return 20
The return value of the child process is : 20
The return value of the waitFor method is : 20


I tried out with a delay of 1 second before calling the exitValue() method, but still facing the same problem.
Yes i am working on a linux platform. Why is that this method behaves differently on this platform?

ajay
[ December 15, 2004: Message edited by: austraind austraind ]
 
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you on Linux? See below:

 
ajay
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Anyone else would like to throw some light on this issue? I am searching for an explanation for this inconsistent behaviour of exitValue method.

Thanks,
Ajay
 
Peter Chase
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see that you've responded to my question by editing the original post. That's a bit confusing, I think, but anyway...

On Linux, some versions of Sun's JVM have a bug in them, where they get the wrong exit code for a process. See bug 4763362. Sun claim it is fixed in 1.4.2, so upgrading your Java version, if you can, might be a fix.
 
ajay
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I checked out the bug id page of sun. But i think the problem is still existing.

I am using JDK1.4.2_04 and the operating system is Red Hat Linux 7.3 2.96-110.

Any other solutions?
 
That feels good. Thanks. Here's a tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic