diff options
| author | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2007-09-18 23:18:46 -0400 |
|---|---|---|
| committer | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2007-09-18 23:18:46 -0400 |
| commit | bab5a1022414de2fbdba5e8674b90b858b1fde1f (patch) | |
| tree | aa1e3fd7a49b67c808443ddb96545a992885f02f | |
| parent | 1c2bbe6a1e8aab256021dcb89439f6602acd2e31 (diff) | |
Add and change error reporting for use in scripts.
| -rw-r--r-- | src/rt_launch.c | 1 | ||||
| -rw-r--r-- | src/set_rt_mode.c | 46 |
2 files changed, 36 insertions, 11 deletions
diff --git a/src/rt_launch.c b/src/rt_launch.c index 31e6447..c82248b 100644 --- a/src/rt_launch.c +++ b/src/rt_launch.c | |||
| @@ -77,6 +77,7 @@ int main(int argc, char** argv) | |||
| 77 | ret = __create_rt_task(launch, &info, cpu, wcet, period, class); | 77 | ret = __create_rt_task(launch, &info, cpu, wcet, period, class); |
| 78 | if (ret < 0) { | 78 | if (ret < 0) { |
| 79 | perror("Could not create rt child process"); | 79 | perror("Could not create rt child process"); |
| 80 | return 2; | ||
| 80 | } | 81 | } |
| 81 | 82 | ||
| 82 | return 0; | 83 | return 0; |
diff --git a/src/set_rt_mode.c b/src/set_rt_mode.c index 5936d7d..510da70 100644 --- a/src/set_rt_mode.c +++ b/src/set_rt_mode.c | |||
| @@ -1,22 +1,46 @@ | |||
| 1 | #include <stdio.h> | 1 | #include <stdio.h> |
| 2 | #include <strings.h> | 2 | #include <strings.h> |
| 3 | #include <stdlib.h> | 3 | #include <stdlib.h> |
| 4 | #include <string.h> | ||
| 5 | #include <errno.h> | ||
| 6 | |||
| 4 | #include "litmus.h" | 7 | #include "litmus.h" |
| 5 | 8 | ||
| 6 | 9 | ||
| 10 | void die(const char* str) | ||
| 11 | { | ||
| 12 | fprintf(stderr, "%s\n%s\n", str, | ||
| 13 | "Usage: set_rt_mode [-v] {on|off}"); | ||
| 14 | exit(127); | ||
| 15 | } | ||
| 16 | |||
| 7 | int main(int argc, char** argv) | 17 | int main(int argc, char** argv) |
| 8 | { | 18 | { |
| 9 | if (argc == 2) { | 19 | int ret; |
| 10 | if (!strcmp(argv[1], "on")) { | 20 | int verbose = 0; |
| 11 | printf("Enabling real-time mode.\n"); | 21 | char* cmd = argv[1]; |
| 12 | set_rt_mode(MODE_RT_RUN); | 22 | |
| 13 | exit(0); | 23 | if (argc == 3 && !strcmp(argv[1], "-v")) { |
| 14 | } else if (!strcmp(argv[1], "off")) { | 24 | verbose = 1; |
| 15 | printf("Disabling real-time mode.\n"); | 25 | cmd = argv[2]; |
| 16 | set_rt_mode(MODE_NON_RT); | 26 | } |
| 17 | exit(0); | 27 | if (argc == 2 || verbose) { |
| 28 | if (!strcmp(cmd, "on")) { | ||
| 29 | if (verbose) | ||
| 30 | printf("Enabling real-time mode.\n"); | ||
| 31 | ret = set_rt_mode(MODE_RT_RUN); | ||
| 32 | if (ret && verbose) | ||
| 33 | perror("set_rt_mode failed"); | ||
| 34 | exit(ret ? errno : 0); | ||
| 35 | } else if (!strcmp(cmd, "off")) { | ||
| 36 | if (verbose) | ||
| 37 | printf("Disabling real-time mode.\n"); | ||
| 38 | ret = set_rt_mode(MODE_NON_RT); | ||
| 39 | if (ret && verbose) | ||
| 40 | perror("set_rt_mode failed"); | ||
| 41 | exit(ret ? errno : 0); | ||
| 18 | } | 42 | } |
| 19 | } | 43 | } |
| 20 | printf("Usage: %s {on|off}\n", argv[0]); | 44 | die("Bad arguments."); |
| 21 | return 1; | 45 | return 0; |
| 22 | } | 46 | } |
