[nut: 1/2] clean pid file on exit (#916468)
Michal Hlavinka
mhlavink at fedoraproject.org
Thu Feb 28 11:39:32 UTC 2013
commit 59230cda4403fffa2cd05426b9f550f0bbe868d4
Author: Michal Hlavinka <mhlavink at redhat.com>
Date: Thu Feb 28 12:38:09 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 bae5652..e87060c 100644
--- a/nut.spec
+++ b/nut.spec
@@ -13,7 +13,7 @@
Summary: Network UPS Tools
Name: nut
Version: 2.6.5
-Release: 9%{?dist}
+Release: 10%{?dist}
Group: Applications/System
License: GPLv2+ and GPLv3+
Url: http://www.networkupstools.org/
@@ -29,6 +29,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 systemd-units
@@ -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
sed -i 's|LIBSSL_LDFLAGS|LIBSSL_LIBS|' lib/libupsclient-config.in
@@ -408,6 +410,9 @@ rm -rf %{buildroot}
%{_libdir}/pkgconfig/libnutscan.pc
%changelog
+* Thu Feb 28 2013 Michal Hlavinka <mhlavink at redhat.com> - 2.6.5-10
+- clean pid file on exit (#916468)
+
* Mon Jan 21 2013 Adam Tkac <atkac redhat com> - 2.6.5-9
- rebuild due to "jpeg8-ABI" feature drop
More information about the scm-commits
mailing list