Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F140098110
D1272.id2657.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D1272.id2657.diff
View Options
Index: sbin/shutdown/shutdown.8
===================================================================
--- sbin/shutdown/shutdown.8
+++ sbin/shutdown/shutdown.8
@@ -118,6 +118,15 @@
The first form brings the system down in
.Ar number
minutes and the second at the absolute time specified.
+.Ar +number
+may be specified in units other than minutes by appending corresponding
+suffix:
+.Dq Li s ,
+.Dq Li sec ,
+.Dq Li m ,
+.Dq Li min .
+.Dq Li h ,
+.Dq Li hour .
.It Ar warning-message
Any other arguments comprise the warning message that is broadcast
to users currently logged into the system.
Index: sbin/shutdown/shutdown.c
===================================================================
--- sbin/shutdown/shutdown.c
+++ sbin/shutdown/shutdown.c
@@ -48,6 +48,7 @@
#include <ctype.h>
#include <err.h>
+#include <errno.h>
#include <fcntl.h>
#include <paths.h>
#include <pwd.h>
@@ -322,7 +323,8 @@
(void)fprintf(pf, "System going down in %d minute%s\n\n",
timeleft / 60, (timeleft > 60) ? "s" : "");
else if (timeleft)
- (void)fprintf(pf, "System going down in 30 seconds\n\n");
+ (void)fprintf(pf, "System going down in %s30 seconds\n\n",
+ (offset > 0 && offset < 30 ? "less than " : ""));
else
(void)fprintf(pf, "System going down IMMEDIATELY\n\n");
@@ -415,6 +417,7 @@
char *p;
time_t now;
int this_year;
+ char *timeunit;
(void)time(&now);
@@ -427,8 +430,25 @@
if (*timearg == '+') { /* +minutes */
if (!isdigit(*++timearg))
badtime();
- if ((offset = atoi(timearg) * 60) < 0)
+ errno = 0;
+ offset = strtol(timearg, &timeunit, 10);
+ if (offset < 0 || offset == LONG_MAX || errno != 0)
badtime();
+ if (timeunit[0] == '\0' || strcasecmp(timeunit, "m") == 0 ||
+ strcasecmp(timeunit, "min") == 0 ||
+ strcasecmp(timeunit, "mins") == 0) {
+ offset *= 60;
+ } else if (strcasecmp(timeunit, "h") == 0 ||
+ strcasecmp(timeunit, "hour") == 0 ||
+ strcasecmp(timeunit, "hours") == 0) {
+ offset *= 60 * 60;
+ } else if (strcasecmp(timeunit, "s") == 0 ||
+ strcasecmp(timeunit, "sec") == 0 ||
+ strcasecmp(timeunit, "secs") == 0) {
+ offset *= 1;
+ } else {
+ badtime();
+ }
shuttime = now + offset;
return;
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Dec 21, 5:01 AM (19 h, 25 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
27107600
Default Alt Text
D1272.id2657.diff (2 KB)
Attached To
Mode
D1272: shutdown: Support time units as in 'shutdown -r +5sec'
Attached
Detach File
Event Timeline
Log In to Comment