2005-04-21 16:53:53 +02:00
|
|
|
/* sleep - suspend a process for x sec Author: Andy Tanenbaum */
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <minix/minlib.h>
|
|
|
|
|
2012-03-24 16:16:34 +01:00
|
|
|
int main(int argc, char **argv);
|
2005-04-21 16:53:53 +02:00
|
|
|
|
|
|
|
int main(argc, argv)
|
|
|
|
int argc;
|
|
|
|
char *argv[];
|
|
|
|
{
|
2012-12-11 18:42:21 +01:00
|
|
|
register int seconds;
|
2005-04-21 16:53:53 +02:00
|
|
|
register char c;
|
|
|
|
|
|
|
|
seconds = 0;
|
|
|
|
|
|
|
|
if (argc != 2) {
|
|
|
|
std_err("Usage: sleep time\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
2012-12-11 18:42:21 +01:00
|
|
|
while ((c = *(argv[1])++)) {
|
2005-04-21 16:53:53 +02:00
|
|
|
if (c < '0' || c > '9') {
|
|
|
|
std_err("sleep: bad arg\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
seconds = 10 * seconds + (c - '0');
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now sleep. */
|
|
|
|
sleep(seconds);
|
|
|
|
return(0);
|
|
|
|
}
|