#include <sys/types.h>

#include <signal.h>
#include <stdlib.h>
#include <unistd.h>

void
child()
{

	printf("Hello, this is child: %d\n", getpid());
	for (;;)
		sleep(5);
}

int
main()
{
	pid_t cpid;
	int status;

	printf("Hello, this is process %d\n", getpid());
	getchar();

	printf("forking .. \n");
	switch (cpid = fork()) {
	case -1:
		perror("fork");
		exit(EXIT_FAILURE);
		/* NOTREACHED */
	case 0:
		child();
		/* NOTREACHED */
	default:
		;
	}

	getchar();
	printf("killing child\n");
	kill(cpid, SIGTERM);

	getchar();
	printf("waited for %d\n", wait(&status));
}
