Updated shutdown to check if time has lapsed when we did not
notice. For example if the computer was in sleep mode pending a shutdown. The shutdown command now notices time has past and adjusts its countdown clock to compensate. Accurate to the nearest minute. Closes Savannah bug #36279
This commit is contained in:
parent
d9b6475d85
commit
a4508479f5
@ -6,6 +6,12 @@ sysvinit (2.90) UNRELEASED; urgency=low
|
|||||||
comparison so the latter is wrote_utmp_rlevel.
|
comparison so the latter is wrote_utmp_rlevel.
|
||||||
* Simplified logic in mountpoint.c when testing for same device or same inode.
|
* Simplified logic in mountpoint.c when testing for same device or same inode.
|
||||||
Thanks to David Binderman for pointing out the above three issues.
|
Thanks to David Binderman for pointing out the above three issues.
|
||||||
|
* When we run shutdown and then the computer is put to sleep, the
|
||||||
|
shutdown command recognizes time has passed and continues its
|
||||||
|
countdown taking the time lapse into consideration. This prevents
|
||||||
|
longer waits if we slept past the time we should have shutdown.
|
||||||
|
Accurate to the nearest minute.
|
||||||
|
Closes Savannah bug #36279.
|
||||||
|
|
||||||
|
|
||||||
sysvinit (2.89) world; urgency=low
|
sysvinit (2.89) world; urgency=low
|
||||||
|
@ -59,7 +59,7 @@
|
|||||||
#include "init.h"
|
#include "init.h"
|
||||||
|
|
||||||
|
|
||||||
char *Version = "@(#) shutdown 2.86-1 31-Jul-2004 miquels@cistron.nl";
|
char *Version = "@(#) shutdown 2.90-1 31-Jul-2004 miquels@cistron.nl";
|
||||||
|
|
||||||
#define MESSAGELEN 256
|
#define MESSAGELEN 256
|
||||||
|
|
||||||
@ -483,7 +483,7 @@ int main(int argc, char **argv)
|
|||||||
struct tm *lt;
|
struct tm *lt;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
struct utmp *ut;
|
struct utmp *ut;
|
||||||
time_t t;
|
time_t t, target_time;
|
||||||
char *halttype;
|
char *halttype;
|
||||||
char *downusers[32];
|
char *downusers[32];
|
||||||
char buf[128];
|
char buf[128];
|
||||||
@ -758,6 +758,17 @@ int main(int argc, char **argv)
|
|||||||
/* Shutdown NOW if time == 0 */
|
/* Shutdown NOW if time == 0 */
|
||||||
if (wt == 0) issue_shutdown(halttype);
|
if (wt == 0) issue_shutdown(halttype);
|
||||||
|
|
||||||
|
/* Rather than loop and reduce wt (wait time) once per minute,
|
||||||
|
we shall check the current time against the target time.
|
||||||
|
Then calculate the remaining wating time based on the difference
|
||||||
|
between current time and target time.
|
||||||
|
This avoids missing shutdown time (target time) after the
|
||||||
|
computer has been asleep. -- Jesse
|
||||||
|
*/
|
||||||
|
/* target time, in seconds = current time + wait time */
|
||||||
|
time(&t);
|
||||||
|
target_time = t + (60 * wt);
|
||||||
|
|
||||||
/* Give warnings on regular intervals and finally shutdown. */
|
/* Give warnings on regular intervals and finally shutdown. */
|
||||||
if (wt < 15 && !needwarning(wt)) issue_warn(wt);
|
if (wt < 15 && !needwarning(wt)) issue_warn(wt);
|
||||||
while(wt) {
|
while(wt) {
|
||||||
@ -767,7 +778,16 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
if (needwarning(wt)) issue_warn(wt);
|
if (needwarning(wt)) issue_warn(wt);
|
||||||
hardsleep(60);
|
hardsleep(60);
|
||||||
wt--;
|
time(&t); /* get current time once per minute */
|
||||||
|
if (t >= target_time) /* past the target */
|
||||||
|
wt = 0;
|
||||||
|
else if ( (target_time - t) <= 60 ) /* less 1 min remains */
|
||||||
|
{
|
||||||
|
hardsleep(target_time - t);
|
||||||
|
wt = 0;
|
||||||
|
}
|
||||||
|
else /* more thsn 1 min remains */
|
||||||
|
wt = (int) (target_time - t) / 60;
|
||||||
}
|
}
|
||||||
issue_shutdown(halttype);
|
issue_shutdown(halttype);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user