From owner-freebsd-ports-bugs@FreeBSD.ORG Thu May 19 08:10:11 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 95FF71065672 for ; Thu, 19 May 2011 08:10: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 694908FC1C for ; Thu, 19 May 2011 08:10: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 p4J8ABDv083746 for ; Thu, 19 May 2011 08:10:11 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id p4J8ABRI083745; Thu, 19 May 2011 08:10:11 GMT (envelope-from gnats) Resent-Date: Thu, 19 May 2011 08:10:11 GMT Resent-Message-Id: <201105190810.p4J8ABRI083745@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-ports-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Zhihao Yuan Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 35242106566B for ; Thu, 19 May 2011 08:00:28 +0000 (UTC) (envelope-from lichray@gmail.com) Received: from mail-iy0-f182.google.com (mail-iy0-f182.google.com [209.85.210.182]) by mx1.freebsd.org (Postfix) with ESMTP id F0D688FC18 for ; Thu, 19 May 2011 08:00:27 +0000 (UTC) Received: by iyj12 with SMTP id 12so2773155iyj.13 for ; Thu, 19 May 2011 01:00:27 -0700 (PDT) Received: by 10.231.74.84 with SMTP id t20mr2101718ibj.38.1305786142120; Wed, 18 May 2011 23:22:22 -0700 (PDT) Received: from compaq.yuetime (c-98-228-191-105.hsd1.il.comcast.net [98.228.191.105]) by mx.google.com with ESMTPS id g16sm987546ibb.20.2011.05.18.23.22.18 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 18 May 2011 23:22:21 -0700 (PDT) Received: by compaq.yuetime (sSMTP sendmail emulation); Thu, 19 May 2011 01:22:13 -0500 Message-Id: <4dd4b71d.d014e70a.5304.507a@mx.google.com> Date: Thu, 19 May 2011 01:22:13 -0500 From: Zhihao Yuan To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Subject: 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 08:10:11 -0000 >Number: 157173 >Category: ports >Synopsis: audio/musicpd: wait --kill to finish (FreeBSD-only) >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Thu May 19 08:10:10 UTC 2011 >Closed-Date: >Last-Modified: >Originator: Zhihao Yuan >Release: FreeBSD 8.2-STABLE amd64 >Organization: >Environment: System: FreeBSD compaq.yuetime 8.2-STABLE FreeBSD 8.2-STABLE #1 r221793M: Wed May 11 21:44:19 CDT 2011 lichray@compaq.yuetime:/home/lichray/temp/obj/home/lichray/devel/freebsd-stable/sys/HOUKAGO amd64 >Description: mpd does not report its pid/pidfile, while it offers a --kill option. But this option only sends the signal, which makes the `rc.d/musicpd restart` always fails (well... may not be always). >How-To-Repeat: >Fix: I wrote a function to use kevent to wait for the pid. I just make it FreeBSD-specific since I don't want to spend time on autotools. The idea is borrowed from src/bin/pwait.c --- musicpd_2-pwait.patch begins here --- diff -ruN --exclude=CVS /usr/ports/audio/musicpd.orig/Makefile /usr/ports/audio/musicpd/Makefile --- /usr/ports/audio/musicpd.orig/Makefile 2011-05-16 08:32:35.000000000 -0500 +++ /usr/ports/audio/musicpd/Makefile 2011-05-19 01:11:44.814689280 -0500 @@ -7,7 +7,7 @@ PORTNAME= musicpd PORTVERSION= 0.16.2 -PORTREVISION= 1 +PORTREVISION= 2 CATEGORIES= audio ipv6 MASTER_SITES= SF/${PORTNAME}/mpd/${PORTVERSION} DISTNAME= mpd-${PORTVERSION} diff -ruN --exclude=CVS /usr/ports/audio/musicpd.orig/files/patch-src_daemon.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:11:29.428807721 -0500 @@ -0,0 +1,45 @@ +--- src/daemon.c.orig 2011-05-19 00:57:23.647296897 -0500 ++++ src/daemon.c 2011-05-19 01:10:01.251176681 -0500 +@@ -37,6 +37,11 @@ + #include + #endif + ++#ifdef __FreeBSD__ ++#include ++#include ++#endif ++ + #undef G_LOG_DOMAIN + #define G_LOG_DOMAIN "daemon" + +@@ -58,6 +63,18 @@ static char *pidfile; + static bool had_group = false; + + ++int pwait(pid_t pid) ++{ ++ int kq = kqueue(); ++ struct kevent kev; ++ EV_SET(&kev, pid, EVFILT_PROC, EV_ADD, NOTE_EXIT, 0, NULL); ++ if (kevent(kq, &kev, 1, NULL, 0, NULL) == -1) ++ return -1; ++ if (kevent(kq, NULL, 0, &kev, 1, NULL)) ++ return WEXITSTATUS(kev.data); ++ return 1; ++} ++ + void + daemonize_kill(void) + { +@@ -79,7 +96,11 @@ daemonize_kill(void) + fclose(fp); + + ret = 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)); + --- musicpd_2-pwait.patch ends here --- >Release-Note: >Audit-Trail: >Unformatted: