Warning: Attempt to read property "date" on null in /usr/local/www/websvn.planix.org/blame.php on line 247

Warning: Attempt to read property "msg" on null in /usr/local/www/websvn.planix.org/blame.php on line 247
WebSVN – planix.SVN – Blame – /os/branches/feature_posix/sys/src/cmd/sleep.c – Rev 2

Subversion Repositories planix.SVN

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
#include <u.h>
2
#include <libc.h>
3
 
4
void
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
}