rewrite and add Berkeley specific header; atoi is in the C library
authorKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Tue, 7 Jun 1988 06:58:18 +0000 (22:58 -0800)
committerKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Tue, 7 Jun 1988 06:58:18 +0000 (22:58 -0800)
yank to rev. level 5

SCCS-vsn: bin/sleep/sleep.c 5.2

usr/src/bin/sleep/sleep.c

index 171849c..0ab8759 100644 (file)
@@ -1,22 +1,38 @@
-static char *sccsid = "@(#)sleep.c     4.1 (Berkeley) %G%";
+/*
+ * Copyright (c) 1988 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that this notice is preserved and that due credit is given
+ * to the University of California at Berkeley. The name of the University
+ * may not be used to endorse or promote products derived from this
+ * software without specific prior written permission. This software
+ * is provided ``as is'' without express or implied warranty.
+ */
+
+#ifndef lint
+char copyright[] =
+"@(#) Copyright (c) 1988 Regents of the University of California.\n\
+ All rights reserved.\n";
+#endif /* not lint */
+
+#ifndef lint
+static char sccsid[] = "@(#)sleep.c    5.2 (Berkeley) %G%";
+#endif /* not lint */
+
+#include <stdio.h>
+
 main(argc, argv)
 main(argc, argv)
-char **argv;
+       int argc;
+       char **argv;
 {
 {
-       int c, n;
-       char *s;
+       int secs;
 
 
-       n = 0;
-       if(argc < 2) {
-               printf("arg count\n");
-               exit(0);
-       }
-       s = argv[1];
-       while(c = *s++) {
-               if(c<'0' || c>'9') {
-                       printf("bad character\n");
-                       exit(0);
-               }
-               n = n*10 + c - '0';
+       if (argc != 2) {
+               fputs("usage: sleep time\n", stderr);
+               exit(1);
        }
        }
-       sleep(n);
+       if ((secs = atoi(argv[1])) > 0)
+               (void)sleep(secs);
+       exit(0);
 }
 }