what happen if child and parent process read from the stdin at the same time?
int main(void){
int pid;
char str[6];
str[5] = 0;
pid = fork();
if (pid)
{
read(0, str, 5);
printf("%s\n", str);
waitpid(pid, 0, 0);
}
else
{
read(0, str, 5);
printf("%s\n", str);
}
as I expected, i will type the keyboard two times, hit enter twice, and it will show two results that I typed. But it didn't! so exactly what happened when two process request stdin at the same time??