summaryrefslogtreecommitdiff
path: root/src/irmd/main.c
diff options
context:
space:
mode:
authordimitri staessens <[email protected]>2017-10-07 11:19:25 +0000
committerSander Vrijders <[email protected]>2017-10-07 11:19:25 +0000
commit51fee46f023ecc05918c3b40cbef90af705b0fe8 (patch)
tree2d6d040eef0dd6aa88c03a082e469c54a51531d5 /src/irmd/main.c
parent7dcacfbc94386e155650aaaa1a8f56cfb6fc53f9 (diff)
parentffdfca4bdf98b571d6a472b1501c3b696807f558 (diff)
downloadouroboros-51fee46f023ecc05918c3b40cbef90af705b0fe8.tar.gz
ouroboros-51fee46f023ecc05918c3b40cbef90af705b0fe8.zip
Merged in dstaesse/ouroboros/be-irmd-version (pull request #623)
irmd: Add option to print version
Diffstat (limited to 'src/irmd/main.c')
-rw-r--r--src/irmd/main.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/src/irmd/main.c b/src/irmd/main.c
index 84c55e93..99a34af2 100644
--- a/src/irmd/main.c
+++ b/src/irmd/main.c
@@ -2272,8 +2272,10 @@ static int irm_init(void)
static void usage(void)
{
- log_err("Usage: irmd \n\n"
- " [--stdout (Print to stdout instead of logs)]\n");
+ printf("Usage: irmd \n"
+ " [--stdout (Log to stdout instead of system log)]\n"
+ " [--version (Print version number and exit)]\n"
+ "\n");
}
int main(int argc,
@@ -2289,11 +2291,6 @@ int main(int argc,
sigaddset(&sigset, SIGHUP);
sigaddset(&sigset, SIGPIPE);
- if (geteuid() != 0) {
- log_err("IPC Resource Manager must be run as root.");
- exit(EXIT_FAILURE);
- }
-
argc--;
argv++;
while (argc > 0) {
@@ -2301,12 +2298,22 @@ int main(int argc,
use_stdout = true;
argc--;
argv++;
+ } else if (strcmp(*argv, "--version") == 0) {
+ printf("Ouroboros version %d.%d\n",
+ OUROBOROS_VERSION_MAJOR,
+ OUROBOROS_VERSION_MINOR);
+ exit(EXIT_SUCCESS);
} else {
usage();
exit(EXIT_FAILURE);
}
}
+ if (geteuid() != 0) {
+ printf("IPC Resource Manager must be run as root.\n");
+ exit(EXIT_FAILURE);
+ }
+
/* Init sig_act. */
memset(&sig_act, 0, sizeof sig_act);
@@ -2369,10 +2376,10 @@ int main(int argc,
pthread_sigmask(SIG_UNBLOCK, &sigset, NULL);
- log_fini();
-
log_info("Bye.");
+ log_fini();
+
exit(EXIT_SUCCESS);
fail_acceptor: