xref: /csrg-svn/bin/sleep/sleep.c (revision 51443)
134660Sbostic /*
234660Sbostic  * Copyright (c) 1988 Regents of the University of California.
334660Sbostic  * All rights reserved.
434660Sbostic  *
542542Sbostic  * %sccs.include.redist.c%
634660Sbostic  */
734660Sbostic 
834660Sbostic #ifndef lint
934660Sbostic char copyright[] =
1034660Sbostic "@(#) Copyright (c) 1988 Regents of the University of California.\n\
1134660Sbostic  All rights reserved.\n";
1234660Sbostic #endif /* not lint */
1334660Sbostic 
1434660Sbostic #ifndef lint
15*51443Sbostic static char sccsid[] = "@(#)sleep.c	5.6 (Berkeley) 10/31/91";
1634660Sbostic #endif /* not lint */
1734660Sbostic 
1847834Sbostic #include <unistd.h>
1934660Sbostic #include <stdio.h>
2047834Sbostic #include <stdlib.h>
2134660Sbostic 
22*51443Sbostic void usage __P((void));
23*51443Sbostic 
241093Sbill main(argc, argv)
2534660Sbostic 	int argc;
26*51443Sbostic 	char *argv[];
271093Sbill {
28*51443Sbostic 	int ch, secs;
291093Sbill 
30*51443Sbostic 	while ((ch = getopt(argc, argv, "")) != EOF)
31*51443Sbostic 		switch(ch) {
32*51443Sbostic 		case '?':
33*51443Sbostic 		default:
34*51443Sbostic 			usage();
35*51443Sbostic 		}
36*51443Sbostic 	argc -= optind;
37*51443Sbostic 	argv += optind;
38*51443Sbostic 
39*51443Sbostic 	if (argc != 1)
40*51443Sbostic 		usage();
41*51443Sbostic 
42*51443Sbostic 	if ((secs = atoi(*argv)) > 0)
4334660Sbostic 		(void)sleep(secs);
4434660Sbostic 	exit(0);
451093Sbill }
46*51443Sbostic 
47*51443Sbostic void
48*51443Sbostic usage()
49*51443Sbostic {
50*51443Sbostic 	(void)fprintf(stderr, "usage: sleep time\n");
51*51443Sbostic 	exit(1);
52*51443Sbostic }
53