xref: /original-bsd/bin/sleep/sleep.c (revision 817cfbae)
1 /*
2  * Copyright (c) 1988 Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  */
7 
8 #ifndef lint
9 char copyright[] =
10 "@(#) Copyright (c) 1988 Regents of the University of California.\n\
11  All rights reserved.\n";
12 #endif /* not lint */
13 
14 #ifndef lint
15 static char sccsid[] = "@(#)sleep.c	5.6 (Berkeley) 10/31/91";
16 #endif /* not lint */
17 
18 #include <unistd.h>
19 #include <stdio.h>
20 #include <stdlib.h>
21 
22 void usage __P((void));
23 
24 main(argc, argv)
25 	int argc;
26 	char *argv[];
27 {
28 	int ch, secs;
29 
30 	while ((ch = getopt(argc, argv, "")) != EOF)
31 		switch(ch) {
32 		case '?':
33 		default:
34 			usage();
35 		}
36 	argc -= optind;
37 	argv += optind;
38 
39 	if (argc != 1)
40 		usage();
41 
42 	if ((secs = atoi(*argv)) > 0)
43 		(void)sleep(secs);
44 	exit(0);
45 }
46 
47 void
48 usage()
49 {
50 	(void)fprintf(stderr, "usage: sleep time\n");
51 	exit(1);
52 }
53