summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2011-08-27 09:20:39 +0200
committerDaniel Friesel <derf@finalrewind.org>2011-08-27 09:20:39 +0200
commit2674577a6f147298f777ce740808a7cf625d6736 (patch)
tree3ab8dfefc23beb19502dce16a0804ab0140d8504
parent841142b6f7c1c387be7538a12dbceca6f7b8f3d3 (diff)
Minor code fixes
* seed random number generator with time [seconds] + PID instead of just time [nanoseconds] * Improve usage message
-rw-r--r--src/randsleep.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/src/randsleep.c b/src/randsleep.c
index 46c6353..bf7bdc3 100644
--- a/src/randsleep.c
+++ b/src/randsleep.c
@@ -5,19 +5,15 @@
int main (int argc, char **argv) {
long maxsleep;
- struct timespec ntime;
if (argc < 2) {
- fputs("Usage: randsleep <max> [<cmd>]\n", stdout);
+ fputs("Usage: randsleep <max> [<cmd> [<args ...>]]\n", stderr);
return 1;
}
maxsleep = atol(argv[1]);
- if (clock_gettime(CLOCK_REALTIME, &ntime) == -1)
- perror("clock_gettime");
-
- srand(ntime.tv_nsec);
+ srand(time(NULL) + getpid());
sleep((rand() % maxsleep) + 1);