/* $Id$ */

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

int main(void)
{
	for (;;) {
		pid_t pid;

		pid = fork();
		if (pid) {
			int st;

			printf("Waiting for %d\n", pid);
			waitpid(pid, &st, 0);

			if (WEXITSTATUS(st) != 123)
				exit(EXIT_SUCCESS);
		} else {
			char *av[] = {"/usr/bin/screen", NULL};

			if (getpid() != 1233)
				exit(123);

			execvp(av[0], av);
			exit(EXIT_FAILURE);
		}
	}
}
