]> mj.ucw.cz Git - ursary.git/commitdiff
Added --no-fork option
authorMartin Mares <mj@ucw.cz>
Sun, 14 Oct 2018 19:33:12 +0000 (21:33 +0200)
committerMartin Mares <mj@ucw.cz>
Sun, 14 Oct 2018 19:33:12 +0000 (21:33 +0200)
ursaryd.c

index 421c701ff5dda005613dcbd6f6bf1abc266a8c0f..c15db3d20b20fb3e81e60b268654120877a60c2a 100644 (file)
--- a/ursaryd.c
+++ b/ursaryd.c
@@ -651,6 +651,7 @@ void notify_touch(int rotary, int on UNUSED)
 /*** Main entry point ***/
 
 static int debug;
+static int no_fork;
 
 static struct opt_section options = {
   OPT_ITEMS {
@@ -659,6 +660,7 @@ static struct opt_section options = {
     OPT_HELP("Options:"),
     OPT_HELP_OPTION,
     OPT_BOOL('d', "debug", debug, 0, "\tEnable debugging mode (no fork etc.)"),
+    OPT_BOOL(0, "no-fork", no_fork, 0, "\tDo not fork\n"),
     OPT_END
   }
 };
@@ -696,7 +698,7 @@ int main(int argc UNUSED, char **argv)
   unsetenv("HOME");
 
   struct daemon_params dp = {
-    .flags = (debug ? DAEMON_FLAG_SIMULATE : 0),
+    .flags = ((debug || no_fork) ? DAEMON_FLAG_SIMULATE : 0),
     .pid_file = "/run/ursaryd.pid",
     .run_as_user = "ursary",
   };