From 8fb64f181ea12a12d9f9e9d58b54298f3e31b84b Mon Sep 17 00:00:00 2001 From: Leah Neukirchen Date: Fri, 7 Jan 2022 16:42:09 +0100 Subject: pass service directory as argv[1] --- rvnit.c | 17 +++++++++++------ 1 file 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); -- cgit 1.4.1