rogue3: replace alarm() calls with a portable function.
Calls to alarm() in main.c are replaced with md_start_checkout_timer(), so the #ifdefs around nonportable code can be confined to mdport.c.
This commit is contained in:
parent
11f7731a3d
commit
b731962f3b
3 changed files with 6 additions and 16 deletions
|
|
@ -374,10 +374,7 @@ setup()
|
||||||
|
|
||||||
if (!author())
|
if (!author())
|
||||||
{
|
{
|
||||||
#ifdef SIGALRM
|
md_start_checkout_timer(CHECKTIME * 60);
|
||||||
signal(SIGALRM, checkout);
|
|
||||||
alarm(CHECKTIME * 60);
|
|
||||||
#endif
|
|
||||||
num_checks = 0;
|
num_checks = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -464,9 +461,6 @@ checkout(int p)
|
||||||
"Last warning. You have %d minutes to leave",
|
"Last warning. You have %d minutes to leave",
|
||||||
};
|
};
|
||||||
int checktime;
|
int checktime;
|
||||||
#ifdef SIGALRM
|
|
||||||
signal(SIGALRM, checkout);
|
|
||||||
#endif
|
|
||||||
if (too_much())
|
if (too_much())
|
||||||
{
|
{
|
||||||
if (num_checks >= 3)
|
if (num_checks >= 3)
|
||||||
|
|
@ -474,9 +468,7 @@ checkout(int p)
|
||||||
checktime = CHECKTIME / (num_checks + 1);
|
checktime = CHECKTIME / (num_checks + 1);
|
||||||
if (num_checks < 3)
|
if (num_checks < 3)
|
||||||
chmsg(msgs[num_checks++], checktime);
|
chmsg(msgs[num_checks++], checktime);
|
||||||
#ifdef SIGALRM
|
md_start_checkout_timer(checktime * 60);
|
||||||
alarm(checktime * 60);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -485,9 +477,7 @@ checkout(int p)
|
||||||
chmsg("The load has dropped back down. You have a reprieve.");
|
chmsg("The load has dropped back down. You have a reprieve.");
|
||||||
num_checks = 0;
|
num_checks = 0;
|
||||||
}
|
}
|
||||||
#ifdef SIGALRM
|
md_start_checkout_timer(CHECKTIME * 60);
|
||||||
alarm(CHECKTIME * 60);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1510,11 +1510,10 @@ md_tstpsignal(void)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(CHECKTIME)
|
|
||||||
void
|
void
|
||||||
md_start_checkout_timer(int time)
|
md_start_checkout_timer(int time)
|
||||||
{
|
{
|
||||||
int checkout();
|
void checkout();
|
||||||
|
|
||||||
#if defined(HAVE_ALARM) && defined(SIGALRM)
|
#if defined(HAVE_ALARM) && defined(SIGALRM)
|
||||||
signal(SIGALRM, checkout);
|
signal(SIGALRM, checkout);
|
||||||
|
|
@ -1529,7 +1528,6 @@ md_stop_checkout_timer(void)
|
||||||
signal(SIGALRM, SIG_IGN);
|
signal(SIGALRM, SIG_IGN);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
long
|
long
|
||||||
md_memused()
|
md_memused()
|
||||||
|
|
|
||||||
|
|
@ -187,6 +187,8 @@ void md_onsignal_exit(void);
|
||||||
void md_onsignal_default(void);
|
void md_onsignal_default(void);
|
||||||
int md_issymlink(char *sp);
|
int md_issymlink(char *sp);
|
||||||
int md_loadav(double *avg);
|
int md_loadav(double *avg);
|
||||||
|
void md_start_checkout_timer(int time);
|
||||||
|
void md_stop_checkout_timer(void);
|
||||||
long md_memused(void);
|
long md_memused(void);
|
||||||
int md_ucount(void);
|
int md_ucount(void);
|
||||||
int md_unlockfile(FILE *fp);
|
int md_unlockfile(FILE *fp);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue