xref: /plan9/sys/src/cmd/sleep.c (revision 7e254d1cd097e70d036c904c3aeb045816b212bf)
1 #include <u.h>
2 #include <libc.h>
3 
4 void
main(int argc,char * argv[])5 main(int argc, char *argv[])
6 {
7 	long n;
8 	char *p, *q;
9 
10 	if(argc>1){
11 		for(n = strtol(argv[1], &p, 0); n > 0; n--)
12 			sleep(1000);
13 		/*
14 		 * no floating point because it is useful to
15 		 * be able to run sleep when bootstrapping
16 		 * a machine.
17 		 */
18 		if(*p++ == '.' && (n = strtol(p, &q, 10)) > 0){
19 			switch(q - p){
20 			case 0:
21 				break;
22 			case 1:
23 				n *= 100;
24 				break;
25 			case 2:
26 				n *= 10;
27 				break;
28 			default:
29 				p[3] = 0;
30 				n = strtol(p, 0, 10);
31 				break;
32 			}
33 			sleep(n);
34 		}
35 	}
36 	exits(0);
37 }
38