Terminate if user chooses not to kill a hung game, and don't delete lockfile

in that case.
Move purge_stale_locks() call to before final endwin() in main().


git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@69 db0b04b0-f4d1-0310-9a6d-de3e77497b0e
This commit is contained in:
Jilles Tjoelker 2004-01-04 02:31:00 +00:00
parent f20200f40c
commit acfec7933e
1 changed files with 11 additions and 4 deletions

View File

@ -1130,7 +1130,7 @@ purge_stale_locks (void)
char *colon;
char buf[16];
pid_t pid;
int seconds = 0;
int seconds;
if (!strcmp(dent->d_name, ".") || !strcmp(dent->d_name, ".."))
continue;
@ -1150,7 +1150,6 @@ purge_stale_locks (void)
graceful_exit (203);
fclose (ipfile);
unlink (dent->d_name);
pid = atoi (buf);
@ -1159,6 +1158,7 @@ purge_stale_locks (void)
errno = 0;
/* Wait for it to stop running */
seconds = 0;
while (kill (pid, 0) == 0)
{
seconds++;
@ -1175,9 +1175,16 @@ purge_stale_locks (void)
kill (pid, SIGTERM);
break;
}
else
{
endwin();
fprintf(stderr, "Sorry, no nethack for you now, please "
"contact the admin.\n");
graceful_exit(1);
}
}
}
seconds = 0;
unlink (dent->d_name);
}
closedir (pdir);
@ -1285,7 +1292,7 @@ main (void)
assert (loggedin);
purge_stale_locks ();
endwin ();
/* environment */