/* * Written by Dmitry V. Levin and placed in the public domain. * Further modifications by Solar Designer, still public domain. * * There's absolutely no warranty. * * $Id: usleep.c,v 1.5 2005/05/07 22:26:06 solar Exp $ */ #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif #include #include #include #include #include #include static void __attribute__ ((__noreturn__)) usage(void) { fprintf(stderr, "usage: %s [microseconds]\n", program_invocation_short_name); exit(EXIT_FAILURE); } int main(int argc, const char **argv) { unsigned long delay = 1; if (argc > 2) usage(); if (argc == 2) { char *p = 0; errno = 0; delay = strtoul(argv[1], &p, 10); if (!*argv[1] || *p || errno) { error(EXIT_SUCCESS, errno ? : EINVAL, "%s", argv[1]); usage(); } } if (usleep(delay)) error(EXIT_FAILURE, errno, "%s", argv[1]); return EXIT_SUCCESS; }