#include <sys/signal.h>

int write(int,char*,int);
int fork(void);
int getpid(void), getppid(void);

int main()
{

int pid;

printf("INITIAL: pid of old process is %d\n",getpid());

if ((pid=fork())==0) {
	/* child code */
	write(1,"CH: inside child\n",13);
	printf("CH: child's pid = %d\n",getpid());
	printf("CH: pid in child (should be zero) %d\n",pid);
	printf("CH: pid of parent's id = %d\n",getppid());
	/* exit(); */
	}
else {
	/* parent's code */
	printf("PAR: inside parent; pid of child is %d\n",pid);
	printf("PAR: pid of parents' parent = %d\n",getppid());
/* 	sleep(20); */
	}

/* common code */
printf("COMMON: printed by process with pid = %d\n",getpid());
}

