summaryrefslogtreecommitdiff
path: root/init.c
diff options
context:
space:
mode:
Diffstat (limited to 'init.c')
-rw-r--r--init.c24
1 files changed, 24 insertions, 0 deletions
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 <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;
+}