File:  [MW Coherent from dump] / coherent / d / bin / sleep.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Wed May 29 04:56:39 2019 UTC (7 years, 2 months ago) by root
Branches: MarkWilliams, MAIN
CVS tags: relic, HEAD
coherent

/*
 * Sleep command
 */

#include <stdio.h>
#include <sys/mdata.h>

long	numeric();
long	atol();

main(argc, argv)
char *argv[];
{
	if (argc > 2)
		usage();
	if (argc > 1)
		lsleep(numeric(argv[1]));
	return (0);
}

/*
 * Check if argument is numeric and
 * return it.
 */
long
numeric(s)
register char *s;
{
	long n;

	n = atol(s);
	for (; *s!='\0'; s++)
		if (*s<'0' || *s>'9')
			usage();
	return (n);
}

/*
 * Sleep that takes a long argument.
 */
lsleep(n)
long n;
{
	register unsigned i;

	while (n > 0) {
		i = n>MAXUINT ? MAXUINT : n;
		sleep(i);
		n -= i;
	}
}

usage()
{
	fprintf(stderr, "Usage: sleep seconds\n");
	exit(1);
}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.