From: Davidlohr Bueso <[email protected]>
When passing an invalid option to monkey we should be returning an EXIT_FAILURE
code indicating the wrong status.
---
src/monkey.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/monkey.c b/src/monkey.c
index 7d0a9e2..5640abb 100644
--- a/src/monkey.c
+++ b/src/monkey.c
@@ -86,7 +86,7 @@ void mk_version()
fflush(stdout);
}
-void mk_help()
+void mk_help(int rc)
{
printf("Usage : monkey [-c directory] [-D] [-v] [-h]\n\n");
printf("Available options:\n");
@@ -94,7 +94,7 @@ void mk_help()
printf(" -D\t\trun Monkey as daemon\n");
printf(" -v\t\tshow version number\n");
printf(" -h\t\tprint this help\n\n");
- exit(EXIT_SUCCESS);
+ exit(rc);
}
/* MAIN */
@@ -123,7 +123,7 @@ int main(int argc, char **argv)
exit(EXIT_SUCCESS);
break;
case 'h':
- mk_help();
+ mk_help(EXIT_SUCCESS);
break;
case 'D':
config->is_daemon = VAR_ON;
@@ -135,7 +135,7 @@ int main(int argc, char **argv)
}
case '?':
printf("Monkey: Invalid option or option needs an argument.\n");
- mk_help();
+ mk_help(EXIT_FAILURE);
break;
}
}
@@ -167,7 +167,7 @@ int main(int argc, char **argv)
mk_utils_worker_spawn((void *) mk_clock_worker_init);
/* Register PID of Monkey */
- mk_utils_register_pid();
+ mk_utils_register_pid();
/* Init mk pointers */
mk_mem_pointers_init();
--
1.7.1
>From 398d8712f28c590d01f4d1730a4b25ae9fccdd49 Mon Sep 17 00:00:00 2001
From: Davidlohr Bueso <[email protected]>
Date: Sun, 6 Feb 2011 10:28:52 -0300
Subject: [PATCH] Fix wrong exit code
When passing an invalid option to monkey we should be returning an EXIT_FAILURE code indicating the wrong status.
---
src/monkey.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/monkey.c b/src/monkey.c
index 7d0a9e2..5640abb 100644
--- a/src/monkey.c
+++ b/src/monkey.c
@@ -86,7 +86,7 @@ void mk_version()
fflush(stdout);
}
-void mk_help()
+void mk_help(int rc)
{
printf("Usage : monkey [-c directory] [-D] [-v] [-h]\n\n");
printf("Available options:\n");
@@ -94,7 +94,7 @@ void mk_help()
printf(" -D\t\trun Monkey as daemon\n");
printf(" -v\t\tshow version number\n");
printf(" -h\t\tprint this help\n\n");
- exit(EXIT_SUCCESS);
+ exit(rc);
}
/* MAIN */
@@ -123,7 +123,7 @@ int main(int argc, char **argv)
exit(EXIT_SUCCESS);
break;
case 'h':
- mk_help();
+ mk_help(EXIT_SUCCESS);
break;
case 'D':
config->is_daemon = VAR_ON;
@@ -135,7 +135,7 @@ int main(int argc, char **argv)
}
case '?':
printf("Monkey: Invalid option or option needs an argument.\n");
- mk_help();
+ mk_help(EXIT_FAILURE);
break;
}
}
@@ -167,7 +167,7 @@ int main(int argc, char **argv)
mk_utils_worker_spawn((void *) mk_clock_worker_init);
/* Register PID of Monkey */
- mk_utils_register_pid();
+ mk_utils_register_pid();
/* Init mk pointers */
mk_mem_pointers_init();
--
1.7.1
_______________________________________________
Monkey mailing list
[email protected]
http://lists.monkey-project.com/listinfo/monkey