From 5059653882dbd86e3bbf48389f9f81b0fac8cd0a Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sun, 17 Mar 2019 19:47:52 +0100 Subject: do not duplicate CONFIG_PID_FILE_PATH and ".pid" strings text data bss dec hex filename 981737 485 7296 989518 f194e busybox_old 981704 485 7296 989485 f192d busybox_unstripped Signed-off-by: Denys Vlasenko --- libbb/pidfile.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'libbb/pidfile.c') diff --git a/libbb/pidfile.c b/libbb/pidfile.c index a48dfc38b..a6a282562 100644 --- a/libbb/pidfile.c +++ b/libbb/pidfile.c @@ -38,3 +38,21 @@ void FAST_FUNC write_pidfile(const char *path) } close(pid_fd); } + +void FAST_FUNC write_pidfile_std_path_and_ext(const char *name) +{ + char buf[sizeof(CONFIG_PID_FILE_PATH) + 64]; + + snprintf(buf, sizeof(buf), CONFIG_PID_FILE_PATH"/%s.pid", name); + write_pidfile(buf); +} + +void FAST_FUNC remove_pidfile_std_path_and_ext(const char *name) +{ + char buf[sizeof(CONFIG_PID_FILE_PATH) + 64]; + + if (!wrote_pidfile) + return; + snprintf(buf, sizeof(buf), CONFIG_PID_FILE_PATH"/%s.pid", name); + unlink(buf); +} -- cgit v1.2.3