summaryrefslogtreecommitdiff
path: root/init.c
blob: b77f3bdb1597e09d89f642a208f9176b494ec4ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <termios.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>

int main(int argc, char *argv[])
{
	chdir("/nethack");
	while(1) {
		pid_t pid = fork();
		if (pid == 0) {
			execl("/nethack/nethack", "/nethack/nethack", NULL);
		} else {
			char buf[1];
			waitpid(pid, NULL, 0);

			/* wait so user can see highscore list */
			write(STDOUT_FILENO, "\n\nPress [Return] to restart.\n", 29);
			read(STDIN_FILENO, buf, sizeof(buf));
			tcflush(STDIN_FILENO, TCIFLUSH);
		}
	}
	return 0;
}