Values of process.exitValue() in JAVA

17,208

That's up to the process in question. Even the "0 means success" is a convention more than anything else - although it's a very common one.

In general I would assume that any non-zero value is an error of some description; look at the documentation for whatever process you're executing for the meaning of specific exit values. If you don't know as the developer what process you're executing (e.g. it's user-specified) then there's no general way of interpreting a non-zero exit code other than "failure".

Share:
17,208
mustafa
Author by

mustafa

Updated on July 16, 2022

Comments

  • mustafa
    mustafa almost 2 years

    This question is about the values of process.exitValue().

    If process.exitValue()=0 its ok, if it's -1 something is wrong, but if it's something else, what does it mean? For instance i am taking 6. That is the code i use:

    Process process = Runtime.getRuntime().exec(command);
    process.waitFor();  
    Integer result = process.exitValue();
    

    Edit: if process hangs, than process.exitValue() = 6