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>
... | ... |
@@ -142,27 +142,6 @@ run_up_down(const char *command, |
142 | 142 |
gc_free(&gc); |
143 | 143 |
} |
144 | 144 |
|
145 |
-/* Write our PID to a file */ |
|
146 |
-void |
|
147 |
-write_pid(const char *filename) |
|
148 |
-{ |
|
149 |
- if (filename) |
|
150 |
- { |
|
151 |
- unsigned int pid = 0; |
|
152 |
- FILE *fp = platform_fopen(filename, "w"); |
|
153 |
- if (!fp) |
|
154 |
- { |
|
155 |
- msg(M_ERR, "Open error on pid file %s", filename); |
|
156 |
- } |
|
157 |
- |
|
158 |
- pid = platform_getpid(); |
|
159 |
- fprintf(fp, "%u\n", pid); |
|
160 |
- if (fclose(fp)) |
|
161 |
- { |
|
162 |
- msg(M_ERR, "Close error on pid file %s", filename); |
|
163 |
- } |
|
164 |
- } |
|
165 |
-} |
|
166 | 145 |
|
167 | 146 |
/* |
168 | 147 |
* Set standard file descriptors to /dev/null |
... | ... |
@@ -33,6 +33,7 @@ |
33 | 33 |
#include "forward.h" |
34 | 34 |
#include "multi.h" |
35 | 35 |
#include "win32.h" |
36 |
+#include "platform.h" |
|
36 | 37 |
|
37 | 38 |
#include "memdbg.h" |
38 | 39 |
|
... | ... |
@@ -47,6 +48,27 @@ process_signal_p2p(struct context *c) |
47 | 47 |
return process_signal(c); |
48 | 48 |
} |
49 | 49 |
|
50 |
+/* Write our PID to a file */ |
|
51 |
+static void |
|
52 |
+write_pid(const char *filename) |
|
53 |
+{ |
|
54 |
+ if (filename) |
|
55 |
+ { |
|
56 |
+ unsigned int pid = 0; |
|
57 |
+ FILE *fp = platform_fopen(filename, "w"); |
|
58 |
+ if (!fp) |
|
59 |
+ { |
|
60 |
+ msg(M_ERR, "Open error on pid file %s", filename); |
|
61 |
+ } |
|
62 |
+ |
|
63 |
+ pid = platform_getpid(); |
|
64 |
+ fprintf(fp, "%u\n", pid); |
|
65 |
+ if (fclose(fp)) |
|
66 |
+ { |
|
67 |
+ msg(M_ERR, "Close error on pid file %s", filename); |
|
68 |
+ } |
|
69 |
+ } |
|
70 |
+} |
|
50 | 71 |
|
51 | 72 |
|
52 | 73 |
/**************************************************************************/ |