Facility to change working directory for daemon
authorAdam Dickmeiss <adam@indexdata.dk>
Thu, 15 Sep 2011 09:12:15 +0000 (11:12 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Thu, 15 Sep 2011 09:12:15 +0000 (11:12 +0200)
Option -wdir sets working directory to dir.

doc/pazpar2.xml
src/pazpar2.c

index 9e346e8..4cbe5f8 100644 (file)
@@ -38,8 +38,9 @@
    <arg choice="opt"><option>-R <replaceable>recfile</replaceable></option></arg>
    <arg choice="opt"><option>-t</option></arg>
    <arg choice="opt"><option>-u <replaceable>uid</replaceable></option></arg>
-   <arg choice="opt"><option>-V</option></arg>
    <arg choice="opt"><option>-v <replaceable>level</replaceable></option></arg>
+   <arg choice="opt"><option>-V</option></arg>
+   <arg choice="opt"><option>-w <replaceable>dir</replaceable></option></arg>
    <arg choice="opt"><option>-X</option></arg>
    <arg choice="opt"><option>-install</option></arg>
    <arg choice="opt"><option>-remove</option></arg>
    </varlistentry>
 
    <varlistentry>
+    <term><option>-v <replaceable>level</replaceable></option></term>
+    <listitem>
+     <para>
+      Sets log level (YAZ log level system).
+     </para>
+    </listitem>
+   </varlistentry>
+
+   <varlistentry>
     <term><option>-V</option></term>
     <listitem>
      <para>
    </varlistentry>
 
    <varlistentry>
-    <term><option>-v <replaceable>level</replaceable></option></term>
+    <term><option>-w <replaceable>dir</replaceable></option></term>
     <listitem>
      <para>
-      Sets log level (YAZ log level system).
+      Changes working directory to <replaceable>dir</replaceable>.
      </para>
     </listitem>
    </varlistentry>
index fcbbca2..f51fa9e 100644 (file)
@@ -152,6 +152,14 @@ static int sc_main(
             break;
         case 'V':
             show_version();
+            break;
+        case 'w':
+            if (chdir(arg))
+            {
+                yaz_log(YLOG_FATAL|YLOG_ERRNO, "chdir %s", arg);
+                return 1;
+            }
+            break;
         case 'X':
             global_parameters.debug_mode++;
             global_parameters.predictable_sessions = 1;
@@ -169,6 +177,7 @@ static int sc_main(
                     "    -u uid                  Change user to uid\n"
                     "    -V                      Show version\n"
                     "    -v level                Set log level\n"
+                    "    -w dir                  Working directory\n"
                     "    -X                      Debug mode\n"
 #ifdef WIN32
                     "    -install                Install windows service\n"