summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/randsleep.111
-rw-r--r--src/randsleep.c12
2 files changed, 18 insertions, 5 deletions
diff --git a/src/randsleep.1 b/src/randsleep.1
index 41d2fac..d051b73 100644
--- a/src/randsleep.1
+++ b/src/randsleep.1
@@ -12,7 +12,8 @@
.Sh SYNOPSIS
.
.Nm
-.Ar time command args ...
+.Ar time
+.Op Ar command args ...
.
.
.Sh VERSION
@@ -32,6 +33,14 @@ after sleeping for up to
seconds.
It is intended for use in cronjobs and similar.
.
+.Pp
+.
+If
+.Ar command
+is not specified,
+.Nm
+will simply return after sleeping.
+.
.
.Sh RATIONALE
.
diff --git a/src/randsleep.c b/src/randsleep.c
index 389e3a7..ea9c588 100644
--- a/src/randsleep.c
+++ b/src/randsleep.c
@@ -7,8 +7,8 @@ int main (int argc, char **argv) {
long maxsleep;
struct timespec ntime;
- if (argc <= 2) {
- fputs("Usage: randsleep <max> <cmd>\n", stdout);
+ if (argc < 2) {
+ fputs("Usage: randsleep <max> [<cmd>]\n", stdout);
return 1;
}
@@ -21,6 +21,10 @@ int main (int argc, char **argv) {
sleep(rand() % maxsleep);
- execvp(argv[2], argv + 2);
- perror("execvp");
+ if (argc > 2) {
+ execvp(argv[2], argv + 2);
+ perror("execvp");
+ }
+
+ return 0;
}