From the
(Please refer them first ;-)):
RETURN VALUE
The value returned is -1 on error (e.g. fork failed), and the return
status of the command otherwise.
Sample:
[baris@rhinox]$ cat return.c
#include <stdlib.h>
int main(int argc, char **argv)
{
int i = system("test 4 -gt 2");
if ( i == -1 )
printf("error\n");
else
printf("$?: %d\n", i);
return 0;
}
[baris@rhinox]$ ./a.out
$?: 0
[baris@rhinox]$ test 4 -gt 2
[baris@rhinox]$ echo $?
0