ports/157173: audio/musicpd: wait --kill to finish (FreeBSD-only)
Zhihao Yuan
lichray at gmail.com
Thu May 19 17:20:12 UTC 2011
The following reply was made to PR ports/157173; it has been noted by GNATS.
From: Zhihao Yuan <lichray at gmail.com>
To: bug-followup at FreeBSD.org
Cc:
Subject: Re: ports/157173: audio/musicpd: wait --kill to finish (FreeBSD-only)
Date: Thu, 19 May 2011 12:17:20 -0500
--QTprm0S8XgL7H0Dt
Content-Type: multipart/mixed; boundary="azLHFNyN32YCQGCU"
Content-Disposition: inline
--azLHFNyN32YCQGCU
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
You can try either to parse the musicpd.conf to get the pidfile, or
implement another option to print the current pid. But, the external
parsing may not be stable, and the second method repeats the code and
changes user interface. I think to do it inside daemon_kill() is the
most stable and simplest way.
Here is an updated patch. The new function is also protected by macro.
--=20
Zhihao Yuan, nickname lichray
The best way to predict the future is to invent it.
___________________________________________________
4BSD -- http://lichray.tumblr.com/
--azLHFNyN32YCQGCU
Content-Type: text/x-diff; charset=iso-8859-1
Content-Disposition: attachment; filename="musicpd_2-pwait.patch"
Content-Transfer-Encoding: quoted-printable
diff -ruN --exclude=3DCVS /usr/ports/audio/musicpd.orig/Makefile /usr/ports=
/audio/musicpd/Makefile
--- /usr/ports/audio/musicpd.orig/Makefile 2011-05-16 08:32:35.000000000 -0=
500
+++ /usr/ports/audio/musicpd/Makefile 2011-05-19 01:11:44.814689280 -0500
@@ -7,7 +7,7 @@
=20
PORTNAME=3D musicpd
PORTVERSION=3D 0.16.2
-PORTREVISION=3D 1
+PORTREVISION=3D 2
CATEGORIES=3D audio ipv6
MASTER_SITES=3D SF/${PORTNAME}/mpd/${PORTVERSION}
DISTNAME=3D mpd-${PORTVERSION}
diff -ruN --exclude=3DCVS /usr/ports/audio/musicpd.orig/files/patch-src_dae=
mon.c /usr/ports/audio/musicpd/files/patch-src_daemon.c
--- /usr/ports/audio/musicpd.orig/files/patch-src_daemon.c 1969-12-31 18:00=
:00.000000000 -0600
+++ /usr/ports/audio/musicpd/files/patch-src_daemon.c 2011-05-19 01:48:56.9=
02381907 -0500
@@ -0,0 +1,48 @@
+--- src/daemon.c.orig 2011-03-18 19:41:52.000000000 -0500
++++ src/daemon.c 2011-05-19 01:47:42.295681718 -0500
+@@ -35,6 +35,11 @@
+ #include <signal.h>
+ #include <pwd.h>
+ #include <grp.h>
++
++#ifdef __FreeBSD__
++#include <sys/event.h>
++#include <sys/wait.h>
++#endif
+ #endif
+=20
+ #undef G_LOG_DOMAIN
+@@ -57,6 +62,21 @@ static char *pidfile;
+ /* whether "group" conf. option was given */
+ static bool had_group =3D false;
+=20
++#ifdef __FreeBSD__
++
++int pwait(pid_t pid)
++{
++ int kq =3D kqueue();
++ struct kevent kev;
++ EV_SET(&kev, pid, EVFILT_PROC, EV_ADD, NOTE_EXIT, 0, NULL);
++ if (kevent(kq, &kev, 1, NULL, 0, NULL) =3D=3D -1)
++ return -1;
++ if (kevent(kq, NULL, 0, &kev, 1, NULL))
++ return WEXITSTATUS(kev.data);
++ return 1;
++}
++
++#endif
+=20
+ void
+ daemonize_kill(void)
+@@ -79,7 +99,11 @@ daemonize_kill(void)
+ fclose(fp);
+=20
+ ret =3D kill(pid, SIGTERM);
++#ifdef __FreeBSD__
++ if (ret < 0 || pwait(pid) < 0)
++#else
+ if (ret < 0)
++#endif
+ MPD_ERROR("unable to kill proccess %i: %s",
+ pid, g_strerror(errno));
+=20
--azLHFNyN32YCQGCU--
--QTprm0S8XgL7H0Dt
Content-Type: application/pgp-signature
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.17 (FreeBSD)
iQEcBAEBAgAGBQJN1VCgAAoJEDM1qsGtFE5ZsSMH/RRRPPbIjnrbIT4ilMR70Gik
Smy/ztsCZ+QYH83KuVaO1Q0P1s8txySCQf7CIIeKAUpefRKhQIlQrBRQiXgx4eWM
iZReJd0DFxFvsblGfbFvfdlsHbXil4lxLznp5lnfDTRo9fKi9eEDfZ5GxhlQTZzN
yVUA6AdZiTe7jIM7F8jkC/yVD1qj3eM43Xh5SiEYmmM5OC8vkO/SeQlay3yWfviB
Yx5LdTfZPnqFqM/KOYldiLmjGWvkMEMmdOoEyVUU+s1t1YL1yipj2QMx8rAT9beC
y+gNXDnAPlZdLXnNNbcmldphWaD6scbtGHXR5jcTwm9olYEIQ13g8mQS0eqeSco=
=YWPg
-----END PGP SIGNATURE-----
--QTprm0S8XgL7H0Dt--
More information about the freebsd-ports-bugs
mailing list