I am learning about xv6 and I create a program like below from a xv6 document:
#include"types.h"
#include"user.h"
#include"param.h"
int main(){
int pid;
pid=fork();
if(pid > 0){
printf(0,"parent: child=%d\n", pid);
pid = wait();
printf(0,"child %d is done\n", pid);
}
else if(pid == 0){
printf(0,"child: exiting\n");
exit();
}
else {
printf(0,"fork error\n");
}
}
I use the wait() syscall to make sure the output of the two processes separated
but they're not:
$ test
cphiarlde:n tex:iti ncg
hild=4
child 4 is done
pid 3 test: trap 14 err 5 on cpu 0 eip 0xffffffff addr 0xffffffff--kill proc
What should I do to fix this problem?