PDA

View Full Version : exitValue() of Process class returns the actual return code from the executable?



indrani ghatare
05-21-2003, 11:59 AM
To determine if an executable I am launching is successful or not, I created a custom bean extending ProductAction. In the bean, I am using the exitValue() method of the process class to get the return code of the executable I am launching. Looks like I am getting the actual return code value from the executable. I was wondering that an article Q105874 mentions that
---"In order to get the exit status of the process, the exitValue() method of the Process class can be used. While this method will not return the actual return code from the executable, it will return "0" to indicate the successful completion of the sub-process, or "1" for failure." ---- while I am getting the actual return code value? Am I missing anything here?

rohanl
05-22-2003, 01:59 AM
Originally posted by indrani ghatare
To determine if an executable I am launching is successful or not, I created a custom bean extending ProductAction. In the bean, I am using the exitValue() method of the process class to get the return code of the executable I am launching. Looks like I am getting the actual return code value from the executable. I was wondering that an article Q105874 mentions that
---"In order to get the exit status of the process, the exitValue() method of the Process class can be used. While this method will not return the actual return code from the executable, it will return "0" to indicate the successful completion of the sub-process, or "1" for failure." ---- while I am getting the actual return code value? Am I missing anything here?

It should be giving the return value from the process - that what Java defines it should do. See here <http://java.sun.com/j2se/1.3/docs/api/java/lang/Process.html> for an example.

It says "0" is by convention success (that's really all you can rely upon). Unfortunately some commands (e.g. grep) give a different return value to mean different things.