diff options
author | David Sommerseth | 2017-07-25 16:57:18 +0200 |
---|---|---|
committer | David Sommerseth | 2017-07-25 17:32:02 +0200 |
commit | cb438b513223744949e0958d9f14870880cfc407 (patch) | |
tree | 708866c1703c93f48744040672ba3c287d7c3378 /src | |
parent | 8295f62f84be3dbc5203b9695d99a4f74fcb7295 (diff) | |
download | openvpn-cb438b513223744949e0958d9f14870880cfc407.zip openvpn-cb438b513223744949e0958d9f14870880cfc407.tar.gz |
cleanup: Move write_pid() to where it is being used
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)
Diffstat (limited to 'src')
-rw-r--r-- | src/openvpn/misc.c | 21 | ||||
-rw-r--r-- | src/openvpn/misc.h | 2 | ||||
-rw-r--r-- | src/openvpn/openvpn.c | 22 |
3 files changed, 22 insertions, 23 deletions
diff --git a/src/openvpn/misc.c b/src/openvpn/misc.c index ae96aa6..8a76bba 100644 --- a/src/openvpn/misc.c +++ b/src/openvpn/misc.c @@ -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 diff --git a/src/openvpn/misc.h b/src/openvpn/misc.h index 32b64e8..734e679 100644 --- a/src/openvpn/misc.h +++ b/src/openvpn/misc.h @@ -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) diff --git a/src/openvpn/openvpn.c b/src/openvpn/openvpn.c index 08c09e6..e237ee5 100644 --- a/src/openvpn/openvpn.c +++ b/src/openvpn/openvpn.c @@ -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); + } + } +} /**************************************************************************/ |