xref: /csrg-svn/bin/sleep/sleep.c (revision 60719)
134660Sbostic /*
2*60719Sbostic  * Copyright (c) 1988, 1993
3*60719Sbostic  *	The Regents of the University of California.  All rights reserved.
434660Sbostic  *
542542Sbostic  * %sccs.include.redist.c%
634660Sbostic  */
734660Sbostic 
834660Sbostic #ifndef lint
9*60719Sbostic static char copyright[] =
10*60719Sbostic "@(#) Copyright (c) 1988, 1993\n\
11*60719Sbostic 	The Regents of the University of California.  All rights reserved.\n";
1234660Sbostic #endif /* not lint */
1334660Sbostic 
1434660Sbostic #ifndef lint
15*60719Sbostic static char sccsid[] = "@(#)sleep.c	8.1 (Berkeley) 05/31/93";
1634660Sbostic #endif /* not lint */
1734660Sbostic 
1847834Sbostic #include <unistd.h>
1934660Sbostic #include <stdio.h>
2047834Sbostic #include <stdlib.h>
2134660Sbostic 
2251443Sbostic void usage __P((void));
2351443Sbostic 
2459517Sbostic int
251093Sbill main(argc, argv)
2634660Sbostic 	int argc;
2751443Sbostic 	char *argv[];
281093Sbill {
2951443Sbostic 	int ch, secs;
301093Sbill 
3151443Sbostic 	while ((ch = getopt(argc, argv, "")) != EOF)
3251443Sbostic 		switch(ch) {
3351443Sbostic 		case '?':
3451443Sbostic 		default:
3551443Sbostic 			usage();
3651443Sbostic 		}
3751443Sbostic 	argc -= optind;
3851443Sbostic 	argv += optind;
3951443Sbostic 
4051443Sbostic 	if (argc != 1)
4151443Sbostic 		usage();
4251443Sbostic 
4351443Sbostic 	if ((secs = atoi(*argv)) > 0)
4434660Sbostic 		(void)sleep(secs);
4534660Sbostic 	exit(0);
461093Sbill }
4751443Sbostic 
4851443Sbostic void
4951443Sbostic usage()
5051443Sbostic {
5159517Sbostic 	(void)fprintf(stderr, "usage: sleep seconds\n");
5251443Sbostic 	exit(1);
5351443Sbostic }
54