I'm trying to know how this code works
#include<stdio.h>
#include<stdlib.h>
#include<sys/wait.h>
#include<unistd.h>
int main()
{
pid_t cpid;
if (fork()== 0)
exit(0);
else
cpid = wait(NULL);
printf("Parent pid = %d\n", getpid());
printf("Child pid = %d\n", cpid);
return 0;
(fork()==0) returns true if we're in the child process. Right?
Then exit(0) will terminate the child process.
Then how will wait(NULL) return the child pid if we can't enter the else case unless we're in a parent process?