/*
 * Problem 2-1
 */

#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <signal.h>

int main()
{
	int pid;

	/*
	 * This just for some more clarity on the screen
	 * And also I set the pid variable to contain the pid 
	 * I don't think we can do it after the fork because 
	 * we couldn't possibly know which process will enter 
	 * the processor queue.
	 */
	printf("PID 1: %d\n", pid=getpid());
	printf("PPID 1: %d\n", getppid());
	
	/*
	 * We create a child process
	 */
	fork();
	
	/*
	 * Now we just kill the parent process...
	 */
	kill(pid, 9);

	/*
	 * And get the information we want.
	 */
	printf("PID 2: %d\n", getpid());
	printf("PPID 2: %d\n", getppid());	 

	exit(0); 
}

/*
###### OUTPUT ######

adimitro@alef:/student/adimitro/cwork> ./a.out
PID 1: 16098
PPID 1: 15407
PID 2: 16099
PPID 2: 1
Killed
adimitro@alef:/student/adimitro/cwork>

*/
