mirror of
https://github.com/paxed/dgamelaunch.git
synced 2025-07-27 07:34:44 +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)
|
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 ();
|
getch ();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1129,6 +1130,7 @@ purge_stale_locks (void)
|
|||||||
char *colon;
|
char *colon;
|
||||||
char buf[16];
|
char buf[16];
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
|
int seconds = 0;
|
||||||
|
|
||||||
colon = strchr (dent->d_name, ':');
|
colon = strchr (dent->d_name, ':');
|
||||||
/* should never happen */
|
/* should never happen */
|
||||||
@ -1150,6 +1152,29 @@ purge_stale_locks (void)
|
|||||||
pid = atoi (buf);
|
pid = atoi (buf);
|
||||||
|
|
||||||
kill (pid, SIGHUP);
|
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);
|
closedir (pdir);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user