Jason Spence ([info]jspence) wrote,
@ 2007-11-05 08:00:00
Previous Entry  Add to memories!  Tell a Friend  Next Entry
The other day, I had to have a shell script sleep for a little bit of time on a embedded Linux box. I couldn't figure out how to do it with the available tools on the box, so I wrote one:
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>

int main(int argc, char * argv[])
{
        struct timeval tv;
        if(argc < 2) {
                fprintf(stderr, "Usage: usleep MICROSECONDS\n");
                return EXIT_FAILURE;
        }
        tv.tv_sec = 0;
        tv.tv_usec = atoi(argv[1]);
        return select(0, NULL, NULL, NULL, &tv);
}



Create an Account
Forgot your login or password?
Login w/ OpenID
English • Español • Deutsch • Русский…