mirror of
https://github.com/paxed/dgamelaunch.git
synced 2025-07-26 23:24:38 +02:00
Reindent, and add some error handling for kill
git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@66 db0b04b0-f4d1-0310-9a6d-de3e77497b0e
This commit is contained in:
parent
0daf7cdb3b
commit
71f367b1b4
@ -563,7 +563,8 @@ domailuser (char *username)
|
||||
{
|
||||
if (errno != EAGAIN)
|
||||
{
|
||||
mvaddstr (10, 1, "Received a weird error from fcntl, so I'm giving up.");
|
||||
mvaddstr (10, 1,
|
||||
"Received a weird error from fcntl, so I'm giving up.");
|
||||
getch ();
|
||||
return;
|
||||
}
|
||||
@ -1129,6 +1130,7 @@ purge_stale_locks (void)
|
||||
char *colon;
|
||||
char buf[16];
|
||||
pid_t pid;
|
||||
int seconds = 0;
|
||||
|
||||
colon = strchr (dent->d_name, ':');
|
||||
/* should never happen */
|
||||
@ -1150,6 +1152,29 @@ purge_stale_locks (void)
|
||||
pid = atoi (buf);
|
||||
|
||||
kill (pid, SIGHUP);
|
||||
|
||||
errno = 0;
|
||||
|
||||
/* Wait for it to stop running */
|
||||
while (kill (pid, 0) == 0)
|
||||
{
|
||||
seconds++;
|
||||
sleep (1);
|
||||
if (seconds == 10)
|
||||
{
|
||||
clear ();
|
||||
drawbanner (1, 1);
|
||||
mvaddstr (3, 1,
|
||||
"Couldn't terminate one of your stale Nethack processes gracefully.");
|
||||
mvaddstr (4, 1, "Force its termination? [yn] ");
|
||||
if (tolower (getch ()) == 'y')
|
||||
{
|
||||
kill (pid, SIGTERM);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
seconds = 0;
|
||||
}
|
||||
|
||||
closedir (pdir);
|
||||
|
Loading…
x
Reference in New Issue
Block a user