Two processes shall communicate with each other. After two seconds the father should send a message to his son, if he's still alive and vice versa. The user can kill one of the two processes entering SIGUSR1 (kill Father) and SIGUSR2 (kill Son). If one process has been killed the other "commits suicide".
I've programmed this so far but it's not working that very well...
Does anybody know what I did wrong?

Code:
#include <stdio.h>
#include <signal.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>


const char *killFather = "1";
const char *killSon = "2";

char *valid1 = "1";
char user[20];
int fd1[2];
int fd2[2];
int pid;


void alarm_handler(int sig) {

	signal(SIGALRM, alarm_handler);
	alarm(2);


	if (pid == 0) {
		if (strcmp(user, killSon) == 0) {
			printf("killed Son");
			valid1 = "0";
			exit(1);
		}

	write(fd1[1], valid1, sizeof(valid1));

	read(fd2[0], valid1, sizeof(valid1));

		if (strcmp(valid1, "0") == 0) {    //Father died
			printf("Child commits suicide");
			exit(1);
		} else {
			printf("Father's still alive\n");
		}


	} else {
		if (strcmp(user, killFather) == 0) {
			printf("killed Father");
			valid1 = "0";
			exit(1);
		}

	write(fd2[1], valid1, strlen(valid1));

	read(fd1[0], valid1, strlen(valid1));

		if (strcmp(valid1, "0") == 0) {
			printf("Father commits suicide");
			exit(1);
		} else {
			printf("Child's still alive\n");
		}
	}
}


void begin() {
	pipe(fd1);
	pipe(fd2);
	pid = fork();

	signal(SIGALRM, alarm_handler);
	alarm(2);
}


int main() {

	begin();
	while(1) {
		scanf("%s", user);
	}

return 0;
}