echo "starting" java TestExit echo $? echo "ending"
public class TestExit{ public static void main(String[] args) { System.out.println("testing exit in java"); } }
starting testing exit in java 0 ending
public class TestExit{ public static void main(String[] args) { System.out.println("testing exit in java"); System.exit(2); } }
starting testing exit in java 2 ending
使用過程當中,System.exit(2)這個值,在一個java程序中,退出JVM時,shell獲取到的並非值2,而是0.java
這是爲何哪?shell