Line | |
---|
1 | /* sleep - suspend a process for x sec Author: Andy Tanenbaum */
|
---|
2 |
|
---|
3 | #include <sys/types.h>
|
---|
4 | #include <stdlib.h>
|
---|
5 | #include <unistd.h>
|
---|
6 | #include <minix/minlib.h>
|
---|
7 |
|
---|
8 | _PROTOTYPE(int main, (int argc, char **argv));
|
---|
9 |
|
---|
10 | int main(argc, argv)
|
---|
11 | int argc;
|
---|
12 | char *argv[];
|
---|
13 | {
|
---|
14 | register seconds;
|
---|
15 | register char c;
|
---|
16 |
|
---|
17 | seconds = 0;
|
---|
18 |
|
---|
19 | if (argc != 2) {
|
---|
20 | std_err("Usage: sleep time\n");
|
---|
21 | exit(1);
|
---|
22 | }
|
---|
23 | while (c = *(argv[1])++) {
|
---|
24 | if (c < '0' || c > '9') {
|
---|
25 | std_err("sleep: bad arg\n");
|
---|
26 | exit(1);
|
---|
27 | }
|
---|
28 | seconds = 10 * seconds + (c - '0');
|
---|
29 | }
|
---|
30 |
|
---|
31 | /* Now sleep. */
|
---|
32 | sleep(seconds);
|
---|
33 | return(0);
|
---|
34 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.