From owner-freebsd-ports-bugs@FreeBSD.ORG Thu May 19 17:20:12 2011 Return-Path: Delivered-To: freebsd-ports-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A1AD11065674 for ; Thu, 19 May 2011 17:20:11 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 84BF88FC19 for ; Thu, 19 May 2011 17:20:11 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id p4JHKBUI043873 for ; Thu, 19 May 2011 17:20:11 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id p4JHKBCd043872; Thu, 19 May 2011 17:20:11 GMT (envelope-from gnats) Date: Thu, 19 May 2011 17:20:11 GMT Message-Id: <201105191720.p4JHKBCd043872@freefall.freebsd.org> To: freebsd-ports-bugs@FreeBSD.org From: Zhihao Yuan Cc: Subject: Re: ports/157173: audio/musicpd: wait --kill to finish (FreeBSD-only) X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Zhihao Yuan List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 May 2011 17:20:12 -0000 The following reply was made to PR ports/157173; it has been noted by GNATS. From: Zhihao Yuan To: bug-followup@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 + #include + #include ++ ++#ifdef __FreeBSD__ ++#include ++#include ++#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--