diff options
| author | Reiner Herrmann <reiner@reiner-h.de> | 2016-01-31 00:39:43 +0100 |
|---|---|---|
| committer | Reiner Herrmann <reiner@reiner-h.de> | 2016-01-31 00:44:06 +0100 |
| commit | 42a9b2c087049f158c9f887a2e0950ebb2e717df (patch) | |
| tree | 829a4e001eaad2f5dfdbba7aaa49a81604fdc4e8 /init.c | |
Initial commit of v2
Diffstat (limited to 'init.c')
| -rw-r--r-- | init.c | 24 |
1 files changed, 24 insertions, 0 deletions
@@ -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; +} |
