This compiles without errors?
int CHILD_STAT;
...
wait_child(child_pid,CHILD_STAT);
...
int wait_child(pid_t wait_pid, int *child_status)
As in, the function expects a POINTER, and you don't pass one.
This compiles without errors?
int CHILD_STAT;
...
wait_child(child_pid,CHILD_STAT);
...
int wait_child(pid_t wait_pid, int *child_status)
As in, the function expects a POINTER, and you don't pass one.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.