xref: /csrg-svn/bin/sleep/sleep.c (revision 66642)
134660Sbostic /*
2*66642Spendry  * Copyright (c) 1988, 1993, 1994
360719Sbostic  *	The Regents of the University of California.  All rights reserved.
434660Sbostic  *
542542Sbostic  * %sccs.include.redist.c%
634660Sbostic  */
734660Sbostic 
834660Sbostic #ifndef lint
960719Sbostic static char copyright[] =
10*66642Spendry "@(#) Copyright (c) 1988, 1993, 1994\n\
1160719Sbostic 	The Regents of the University of California.  All rights reserved.\n";
1234660Sbostic #endif /* not lint */
1334660Sbostic 
1434660Sbostic #ifndef lint
15*66642Spendry static char sccsid[] = "@(#)sleep.c	8.3 (Berkeley) 04/02/94";
1634660Sbostic #endif /* not lint */
1734660Sbostic 
1834660Sbostic #include <stdio.h>
1947834Sbostic #include <stdlib.h>
2066563Spendry #include <unistd.h>
2134660Sbostic 
2251443Sbostic void usage __P((void));
2351443Sbostic 
2459517Sbostic int
main(argc,argv)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
usage()4951443Sbostic usage()
5051443Sbostic {
5166563Spendry 
5259517Sbostic 	(void)fprintf(stderr, "usage: sleep seconds\n");
5351443Sbostic 	exit(1);
5451443Sbostic }
55