I thought wait paused the main execution untill child process finished.
The following is what I was expecting to see in the console.
I am the parent with id 12833 <- parent
I'm calling first with id 0 <- child
I'm calling first with id 12833 <- parent after wait()
Instead I see this... #console output
I am the parent with id 12833
I'm calling first with id 12833
I'm calling first with id 0
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
int main(int argc, char* argv[])
{
int id = fork();
if(id!=0){
//
printf("I am the parent with id %d\n",id);
wait(); //my code has no respect for wait()
}
printf("I'm calling first with id %d\n",id);
return 0;
}