#include <stdio.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <ctype.h>

int main ()
{
	int fd[2];
	pid_t pid;
	char c;
	char buf[1024];
	unsigned int i;

	pipe(fd);
	pid = fork ();
	if (pid == (pid_t) 0)
	{
		read(fd[0], buf, sizeof(buf));
		for (i = 0; buf[i] != '\0'; i++)
		{
			c = (char)toupper(buf[i]);
			write(fd[1], &c, 1);
		}
		close(fd[0]);
		close(fd[1]);
	}
	else {
		write(fd[1], "Witam.\n", 7);
		close(fd[1]);
		waitpid(pid, NULL, (int)NULL);

		while (read(fd[0], &c, 1) > 0)
		{
			putchar(c);
		}
	}

	return 0;
}
