1 From 4119652f74ce6f8f370df3c80076792d509bc941 Mon Sep 17 00:00:00 2001
2 From: Andreas Oberritter <obi@opendreambox.org>
3 Date: Mon, 14 May 2012 16:15:50 +0200
4 Subject: [PATCH 7/9] ifplugd: move read_pid to libbb/pidfile.c and rename it
7 Signed-off-by: Andreas Oberritter <obi@opendreambox.org>
10 libbb/pidfile.c | 14 ++++++++++++++
11 networking/ifplugd.c | 18 +-----------------
12 3 files changed, 17 insertions(+), 17 deletions(-)
14 diff --git a/include/libbb.h b/include/libbb.h
15 index 63d0419..e9538e7 100644
18 @@ -1031,10 +1031,12 @@ llist_t *llist_find_str(llist_t *first, const char *str) FAST_FUNC;
19 #if ENABLE_FEATURE_PIDFILE || defined(WANT_PIDFILE)
20 /* True only if we created pidfile which is *file*, not /dev/null etc */
21 extern smallint wrote_pidfile;
22 +pid_t read_pidfile(const char *path) FAST_FUNC;
23 void write_pidfile(const char *path) FAST_FUNC;
24 #define remove_pidfile(path) do { if (wrote_pidfile) unlink(path); } while (0)
26 enum { wrote_pidfile = 0 };
27 +#define read_pidfile(path) ((void)0)
28 #define write_pidfile(path) ((void)0)
29 #define remove_pidfile(path) ((void)0)
31 diff --git a/libbb/pidfile.c b/libbb/pidfile.c
32 index a48dfc3..6734a2d 100644
37 smallint wrote_pidfile;
39 +pid_t FAST_FUNC read_pidfile(const char *filename)
44 + len = open_read_close(filename, buf, 127);
47 + /* returns ULONG_MAX on error => -1 */
48 + return bb_strtoul(buf, NULL, 10);
53 void FAST_FUNC write_pidfile(const char *path)
56 diff --git a/networking/ifplugd.c b/networking/ifplugd.c
57 index d8358cd..9a15576 100644
58 --- a/networking/ifplugd.c
59 +++ b/networking/ifplugd.c
60 @@ -510,22 +510,6 @@ static NOINLINE int check_existence_through_netlink(void)
61 return G.iface_exists;
64 -#if ENABLE_FEATURE_PIDFILE
65 -static NOINLINE pid_t read_pid(const char *filename)
70 - len = open_read_close(filename, buf, 127);
73 - /* returns ULONG_MAX on error => -1 */
74 - return bb_strtoul(buf, NULL, 10);
80 int ifplugd_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
81 int ifplugd_main(int argc UNUSED_PARAM, char **argv)
83 @@ -552,7 +536,7 @@ int ifplugd_main(int argc UNUSED_PARAM, char **argv)
85 #if ENABLE_FEATURE_PIDFILE
86 pidfile_name = xasprintf(_PATH_VARRUN"ifplugd.%s.pid", G.iface);
87 - pid_from_pidfile = read_pid(pidfile_name);
88 + pid_from_pidfile = read_pidfile(pidfile_name);
90 if (opts & FLAG_KILL) {
91 if (pid_from_pidfile > 0)