]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
cleanup: Move write_pid() to where it is being used
authorDavid Sommerseth <davids@openvpn.net>
Tue, 25 Jul 2017 14:57:18 +0000 (16:57 +0200)
committerDavid Sommerseth <davids@openvpn.net>
Tue, 25 Jul 2017 15:32:02 +0000 (17:32 +0200)
The write_pid() function is only used in openvpn.c, so no
need to have that in the misc.[ch] mixed bag.

[on-the-fly change: Added #include "platform.h"]

Signed-off-by: David Sommerseth <davids@openvpn.net>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <20170725145718.13175-1-davids@openvpn.net>
URL: https://www.mail-archive.com/search?l=mid&q=20170725145718.13175-1-davids@openvpn.net
Signed-off-by: David Sommerseth <davids@openvpn.net>
(cherry picked from commit c5b12817c9aa3ae97fbdd2c2a9a9ab605087dff1)

src/openvpn/misc.c
src/openvpn/misc.h
src/openvpn/openvpn.c

index ae96aa690258cb127a30df11f5267d12de965ab3..8a76bba89c6c7c23fefd82a9d986d8d132eb9dae 100644 (file)
@@ -142,27 +142,6 @@ run_up_down(const char *command,
     gc_free(&gc);
 }
 
-/* Write our PID to a file */
-void
-write_pid(const char *filename)
-{
-    if (filename)
-    {
-        unsigned int pid = 0;
-        FILE *fp = platform_fopen(filename, "w");
-        if (!fp)
-        {
-            msg(M_ERR, "Open error on pid file %s", filename);
-        }
-
-        pid = platform_getpid();
-        fprintf(fp, "%u\n", pid);
-        if (fclose(fp))
-        {
-            msg(M_ERR, "Close error on pid file %s", filename);
-        }
-    }
-}
 
 /*
  * Set standard file descriptors to /dev/null
index 32b64e8bb15c2629b0f711d955f9dbf0af6c5e46..734e679c5edfab6a534b76ddf4bf5097a4465d24 100644 (file)
@@ -68,8 +68,6 @@ void run_up_down(const char *command,
                  const char *script_type,
                  struct env_set *es);
 
-void write_pid(const char *filename);
-
 /* system flags */
 #define S_SCRIPT (1<<0)
 #define S_FATAL  (1<<1)
index 08c09e6bedb1d56076682ca1705c6e7bf2561308..e237ee5042c45950e30d5002f35b8e980442cec3 100644 (file)
@@ -33,6 +33,7 @@
 #include "forward.h"
 #include "multi.h"
 #include "win32.h"
+#include "platform.h"
 
 #include "memdbg.h"
 
@@ -47,6 +48,27 @@ process_signal_p2p(struct context *c)
     return process_signal(c);
 }
 
+/* Write our PID to a file */
+static void
+write_pid(const char *filename)
+{
+    if (filename)
+    {
+        unsigned int pid = 0;
+        FILE *fp = platform_fopen(filename, "w");
+        if (!fp)
+        {
+            msg(M_ERR, "Open error on pid file %s", filename);
+        }
+
+        pid = platform_getpid();
+        fprintf(fp, "%u\n", pid);
+        if (fclose(fp))
+        {
+            msg(M_ERR, "Close error on pid file %s", filename);
+        }
+    }
+}
 
 
 /**************************************************************************/