Sisyphus repository
Last update: 1 october 2023 | SRPMs: 18631 | Visits: 37805339
en ru br
ALT Linux repos
S:9.4.0.24.75e248-alt1
5.0: 6.12-alt2
4.1: 6.11-alt1
4.0: 5.97-alt6
3.0: 5.3.1-alt0.4

Other repositories
Upstream:8.1pl3

Group :: System/Base
RPM: coreutils

 Main   Changelog   Spec   Patches   Sources   Download   Gear   Bugs and FR  Repocop 

/*
* 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 <stdio.h>
#include <errno.h>
#include <error.h>
#include <stdlib.h>
#include <limits.h>
#include <unistd.h>

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;
}
 
design & coding: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
current maintainer: Michael Shigorin