#include #include #include #include #include #include int main() { char * p; p = malloc(10); strcpy(p, "abcd"); /* bad programming, should always check a system call returning -1 */ if (fork() == 0) { printf("child process, pid = %d, p = %p, content(p) = %s\n", getpid(), (void *)p, p); strcpy(p, "kkkkk"); } else { wait(NULL); /* parent wait for child to finish */ } printf("pid = %d, p = %p, content(p) = %s\n", getpid(), (void *)p, p); return(EXIT_SUCCESS); }