[nut/f17] clean pid file on exit (#916468)

Michal Hlavinka mhlavink at fedoraproject.org
Thu Feb 28 11:52:45 UTC 2013


commit 0b30a7673835cdb457229a77bf2fa5605eddb704
Author: Michal Hlavinka <mhlavink at redhat.com>
Date:   Thu Feb 28 12:52:34 2013 +0100

    clean pid file on exit (#916468)

 nut-2.6.5-rmpidf.patch |   59 ++++++++++++++++++++++++++++++++++++++++++++++++
 nut.spec               |    7 +++++-
 2 files changed, 65 insertions(+), 1 deletions(-)
---
diff --git a/nut-2.6.5-rmpidf.patch b/nut-2.6.5-rmpidf.patch
new file mode 100644
index 0000000..ada8d70
--- /dev/null
+++ b/nut-2.6.5-rmpidf.patch
@@ -0,0 +1,59 @@
+diff -up nut-2.6.5/clients/upsmon.c.rmpidf nut-2.6.5/clients/upsmon.c
+--- nut-2.6.5/clients/upsmon.c.rmpidf	2013-02-28 12:08:34.487394359 +0100
++++ nut-2.6.5/clients/upsmon.c	2013-02-28 12:08:34.494394419 +0100
+@@ -2037,6 +2037,7 @@ int main(int argc, char *argv[])
+ 
+ 	upslogx(LOG_INFO, "Signal %d: exiting", exit_flag);
+ 	upsmon_cleanup();
++	cleanpid(prog);
+ 
+ 	exit(EXIT_SUCCESS);
+ }
+diff -up nut-2.6.5/common/common.c.rmpidf nut-2.6.5/common/common.c
+--- nut-2.6.5/common/common.c.rmpidf	2012-07-31 19:38:58.000000000 +0200
++++ nut-2.6.5/common/common.c	2013-02-28 12:08:34.494394419 +0100
+@@ -229,6 +229,20 @@ void writepid(const char *name)
+ 	umask(mask);
+ }
+ 
++/* remove pid file */
++void cleanpid(const char *name)
++{
++	char	fn[SMALLBUF];
++
++	/* use full path if present, else build filename in PIDPATH */
++	if (*name == '/')
++		snprintf(fn, sizeof(fn), "%s", name);
++	else
++		snprintf(fn, sizeof(fn), "%s/%s.pid", PIDPATH, name);
++
++	unlink(fn);
++}
++
+ /* open pidfn, get the pid, then send it sig */
+ int sendsignalfn(const char *pidfn, int sig)
+ {
+diff -up nut-2.6.5/include/common.h.rmpidf nut-2.6.5/include/common.h
+--- nut-2.6.5/include/common.h.rmpidf	2012-07-31 19:38:56.000000000 +0200
++++ nut-2.6.5/include/common.h	2013-02-28 12:08:34.495394429 +0100
+@@ -64,6 +64,9 @@ void chroot_start(const char *path);
+ /* write a pid file - <name> is a full pathname *or* just the program name */
+ void writepid(const char *name);
+ 
++/* remove pid file */
++void cleanpid(const char *name);
++
+ /* send a signal to another running process */
+ int sendsignal(const char *progname, int sig);
+ 
+diff -up nut-2.6.5/server/upsd.c.rmpidf nut-2.6.5/server/upsd.c
+--- nut-2.6.5/server/upsd.c.rmpidf	2013-02-28 12:08:37.967424582 +0100
++++ nut-2.6.5/server/upsd.c	2013-02-28 12:08:37.982424720 +0100
+@@ -1040,6 +1040,7 @@ int main(int argc, char **argv)
+ 	}
+ 
+ 	upslogx(LOG_INFO, "Signal %d: exiting", exit_flag);
++	if (*pidfn) cleanpid(pidfn);
+ 	return EXIT_SUCCESS;
+ }
+ 
diff --git a/nut.spec b/nut.spec
index 8d6d88a..0b25e97 100644
--- a/nut.spec
+++ b/nut.spec
@@ -14,7 +14,7 @@
 Summary: Network UPS Tools
 Name: nut
 Version: 2.6.5
-Release: 6%{?dist}
+Release: 7%{?dist}
 Group: Applications/System
 License: GPLv2+
 Url: http://www.networkupstools.org/
@@ -30,6 +30,7 @@ Patch5: nut-2.6.5-dlfix.patch
 Patch6: nut-2.6.5-pthreadfix.patch
 Patch7: nut-2.6.5-foreground.patch
 Patch8: nut-2.6.5-unreachable.patch
+Patch9: nut-2.6.5-rmpidf.patch
 
 Requires(pre): shadow-utils udev
 Requires(post): fileutils chkconfig 
@@ -124,6 +125,7 @@ necessary to develop NUT client applications.
 %patch6 -p1 -b .pthreadfix
 %patch7 -p1 -b .foreground
 %patch8 -p1 -b .unreachable
+%patch9 -p1 -b .rmpidf
 
 sed -i 's|=NUT-Monitor|=nut-monitor|'  scripts/python/app/nut-monitor.desktop
 sed -i "s|sys.argv\[0\]|'%{_datadir}/%{name}/nut-monitor/nut-monitor'|" scripts/python/app/NUT-Monitor
@@ -507,6 +509,9 @@ rm -rf %{buildroot}
 %{_libdir}/pkgconfig/libnutscan.pc
 
 %changelog
+* Thu Feb 28 2013 Michal Hlavinka <mhlavink at redhat.com> - 2.6.5-7
+- clean pid file on exit (#916468)
+
 * Mon Jan 07 2013 Michal Hlavinka <mhlavink at redhat.com> - 2.6.5-6
 - do not traceback when ups is not reachable
 


More information about the scm-commits mailing list