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.7 (Berkeley) 04/29/93"; 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 int 25 main(argc, argv) 26 int argc; 27 char *argv[]; 28 { 29 int ch, secs; 30 31 while ((ch = getopt(argc, argv, "")) != EOF) 32 switch(ch) { 33 case '?': 34 default: 35 usage(); 36 } 37 argc -= optind; 38 argv += optind; 39 40 if (argc != 1) 41 usage(); 42 43 if ((secs = atoi(*argv)) > 0) 44 (void)sleep(secs); 45 exit(0); 46 } 47 48 void 49 usage() 50 { 51 (void)fprintf(stderr, "usage: sleep seconds\n"); 52 exit(1); 53 } 54