aboutsummaryrefslogtreecommitdiffstats
path: root/usr/sleep.c
blob: 3c229dfac05bf2b2a8b4d4578c34422e80a737e9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include "gbos.h"
/* sleep N: wait N seconds (the kernel counts 1/64 s ticks, so N is capped at
 * what fits: 3 seconds per gsleep call, looped). Mostly useful in scripts and
 * to pace a background job. */
void main(void) {
    char *argv[4];
    unsigned char argc = argv_parse(argv, 4);
    unsigned char n, i;
    if (argc < 1) {
        puts("usage: sleep SECONDS");
        nl();
        sexit(2);
    }
    n = atou(argv[0]);
    for (i = 0; i < n; i++) gsleep(64); /* 64 ticks = one second */
}