diff options
author | Taru Karttunen <taruti@taruti.net> | 2011-03-30 15:46:40 +0300 |
---|---|---|
committer | Taru Karttunen <taruti@taruti.net> | 2011-03-30 15:46:40 +0300 |
commit | e5888a1ffdae813d7575f5fb02275c6bb07e5199 (patch) | |
tree | d8d51eac403f07814b9e936eed0c9a79195e2450 /sys/src/cmd/sleep.c |
Import sources from 2011-03-30 iso image
Diffstat (limited to 'sys/src/cmd/sleep.c')
-rwxr-xr-x | sys/src/cmd/sleep.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/sys/src/cmd/sleep.c b/sys/src/cmd/sleep.c new file mode 100755 index 000000000..0a8673bda --- /dev/null +++ b/sys/src/cmd/sleep.c @@ -0,0 +1,37 @@ +#include <u.h> +#include <libc.h> + +void +main(int argc, char *argv[]) +{ + long n; + char *p, *q; + + if(argc>1){ + for(n = strtol(argv[1], &p, 0); n > 0; n--) + sleep(1000); + /* + * no floating point because it is useful to + * be able to run sleep when bootstrapping + * a machine. + */ + if(*p++ == '.' && (n = strtol(p, &q, 10)) > 0){ + switch(q - p){ + case 0: + break; + case 1: + n *= 100; + break; + case 2: + n *= 10; + break; + default: + p[3] = 0; + n = strtol(p, 0, 10); + break; + } + sleep(n); + } + } + exits(0); +} |