From 42a9b2c087049f158c9f887a2e0950ebb2e717df Mon Sep 17 00:00:00 2001 From: Reiner Herrmann Date: Sun, 31 Jan 2016 00:39:43 +0100 Subject: Initial commit of v2 --- init.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 init.c (limited to 'init.c') diff --git a/init.c b/init.c new file mode 100644 index 0000000..b77f3bd --- /dev/null +++ b/init.c @@ -0,0 +1,24 @@ +#include +#include +#include +#include + +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; +} -- cgit v1.2.3