summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2022-01-07 16:42:09 +0100
committerLeah Neukirchen <leah@vuxu.org>2022-01-07 16:42:09 +0100
commit8fb64f181ea12a12d9f9e9d58b54298f3e31b84b (patch)
tree88daf66dad1f6324347eed2abe1b61a68d2f4b2b
parent07ba00058350948a8a5e89aa312c6f5b12098d93 (diff)
downloadrvnit-8fb64f181ea12a12d9f9e9d58b54298f3e31b84b.tar.gz
rvnit-8fb64f181ea12a12d9f9e9d58b54298f3e31b84b.tar.xz
rvnit-8fb64f181ea12a12d9f9e9d58b54298f3e31b84b.zip
pass service directory as argv[1]
-rw-r--r--rvnit.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/rvnit.c b/rvnit.c
index 4fa1968..b35850b 100644
--- a/rvnit.c
+++ b/rvnit.c
@@ -555,8 +555,18 @@ next:		;
 }
 
 int
-main()
+main(int argc, char *argv[])
 {
+	if (argc < 2) {
+		dprintf(2, "Usage: rvnit DIR\n");
+		exit(2);
+	}
+
+	if (chdir(argv[1]) < 0) {
+		perror("chdir");
+		return 111;
+	}
+
 	pipe(selflogfd);
 	fcntl(selflogfd[0], F_SETFL, O_NONBLOCK);
 	fcntl(selflogfd[1], F_SETFL, O_NONBLOCK);
@@ -584,11 +594,6 @@ main()
 	pthread_create(&logger_thread, 0, logger_loop, 0);
 	sigprocmask(SIG_UNBLOCK, &allset, 0);
 
-	if (chdir("sv") < 0) {
-		perror("chdir");
-		return 111;
-	}
-
 	pthread_mutex_lock(&services_lock);
 	rescandir();
 	pthread_mutex_unlock(&services_lock);