I have read in books and online resources that the fork() system call creates a copy of current process and both the processes start executing from the point after the fork() system call is made. Is it correct?
If it is correct then why does the code below print "Test Test"? It should print "Test" just one time (by the parent process).
#include <sys/types.h> /* pid_t */
#include <sys/wait.h> /* waitpid */
#include <stdio.h> /* printf, perror */
#include <stdlib.h> /* exit */
#include <unistd.h> /* _exit, fork */
int main(void)
{
int ctr =1;
int pc = 1;
printf("%s", "Test ");
pid_t pidmain = fork();
return EXIT_SUCCESS;
}