Java Code:
public class Test {
public static void main ( String[] args ) {
System.exit ( 4 );
}
}
C ++ Code:
#include <stdio.h>
#include <cstdlib>
int main() {
int result = system ( "java Test" );
printf ( "Result: %d", result );
}
Running these c ++ programs
"Result: 1024"
Should I run the java program directly and check the return state value with bash $? variable i get 4:
> java Test
> echo $?
4
So, it seems I do not understand or am using the System call incorrectly.
How to get this return value of "4" from a call to system (), not "1024", but where does "1024" come from?
Thanks!
source
share