summaryrefslogtreecommitdiff
path: root/src/randsleep.c
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2011-07-08 09:49:46 +0200
committerDaniel Friesel <derf@finalrewind.org>2011-07-08 09:49:46 +0200
commit0e80b23b5efd17fcc12a79485b2bd55186b8500a (patch)
tree0a688ccd130117e11daad69b4fd4761e4eca3b7e /src/randsleep.c
parent1f28f34dade2276b42c4a11bd8f81945473fce5f (diff)
Make command argument optional
Diffstat (limited to 'src/randsleep.c')
-rw-r--r--src/randsleep.c12
1 files changed, 8 insertions, 4 deletions
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;
}