Hi,
I think its not because of the different compiler, its because may be synchronization of parent and child is not happening properly, wait is getting executed even before child process starting.. or something like that?
anyway,
try this code and see what happened:
pid = fork();
switch(pid){
case -1:
perror("Fork failed");
exit(1);
case 0:
//this is child;
break;
default:
//parent
break;
}
if(pid != 0)
{
int stat_val;
pid_t child_pid;
child_pid = wait(&stat_val);
if(WIFEXISTED)
printf("Child has terminated with exit code %d\n", WIFEXISTED(stat_val));
else
printf("Child has existed abnormally\n");
}
// Do some child code here..