View | Details | Raw Unified | Return to bug 264162
Collapse All | Expand All

(-)b/bin/sleep/sleep.1 (-2 / +10 lines)
Lines 40-52 Link Here
40
.Nd suspend execution for an interval of time
40
.Nd suspend execution for an interval of time
41
.Sh SYNOPSIS
41
.Sh SYNOPSIS
42
.Nm
42
.Nm
43
.Ar seconds
43
.Ar number[unit]
44
.Sh DESCRIPTION
44
.Sh DESCRIPTION
45
The
45
The
46
.Nm
46
.Nm
47
command
47
command
48
suspends execution for a minimum of
48
suspends execution for a minimum of
49
.Ar seconds .
49
.Ar number
50
seconds (the default, or unit
51
.Ar s ) ,
52
or minutes (unit
53
.Ar m ) ,
54
hours (unit
55
.Ar h ) ,
56
or days (unit
57
.Ar d ) .
50
.Pp
58
.Pp
51
If the
59
If the
52
.Nm
60
.Nm
(-)b/bin/sleep/sleep.c (-3 / +15 lines)
Lines 66-71 main(int argc, char *argv[]) Link Here
66
	struct timespec time_to_sleep;
66
	struct timespec time_to_sleep;
67
	double d;
67
	double d;
68
	time_t original;
68
	time_t original;
69
	char unit;
69
	char buf[2];
70
	char buf[2];
70
71
71
	if (caph_limit_stdio() < 0 || caph_enter() < 0)
72
	if (caph_limit_stdio() < 0 || caph_enter() < 0)
Lines 74-81 main(int argc, char *argv[]) Link Here
74
	if (argc != 2)
75
	if (argc != 2)
75
		usage();
76
		usage();
76
77
77
	if (sscanf(argv[1], "%lf%1s", &d, buf) != 1)
78
	if (sscanf(argv[1], "%lf%c%1s", &d, &unit, buf) != 1)
78
		usage();
79
		switch(unit) {
80
			case 'd': d *= 24;
81
			case 'h': d *= 60;
82
			case 'm': d *= 60;
83
			case 's': break;
84
			default:  usage();
85
		}
86
	else
87
		if (sscanf(argv[1], "%lf%1s", &d, buf) != 1)
88
			usage();
79
	if (d > INT_MAX)
89
	if (d > INT_MAX)
80
		usage();
90
		usage();
81
	if (d <= 0)
91
	if (d <= 0)
Lines 106-111 static void Link Here
106
usage(void)
116
usage(void)
107
{
117
{
108
118
109
	fprintf(stderr, "usage: sleep seconds\n");
119
	fprintf(stderr, "usage: sleep number[unit]\n");
120
	fprintf(stderr, "Unit can be 's' (seconds, the default), "
121
			"m (minutes), h (hours), or d (days).\n");
110
	exit(1);
122
	exit(1);
111
}
123
}

Return to bug 264162