public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] repo/gentoo:master commit in: sys-apps/netplug/, sys-apps/netplug/files/
@ 2019-04-20 23:07 Lars Wendler
  0 siblings, 0 replies; only message in thread
From: Lars Wendler @ 2019-04-20 23:07 UTC (permalink / raw
  To: gentoo-commits

commit:     ca3c5c6b52e60bea1eab05a2b5bc97942aa7dc66
Author:     Lars Wendler <polynomial-c <AT> gentoo <DOT> org>
AuthorDate: Sat Apr 20 23:02:50 2019 +0000
Commit:     Lars Wendler <polynomial-c <AT> gentoo <DOT> org>
CommitDate: Sat Apr 20 23:06:17 2019 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ca3c5c6b

sys-apps/netplug: Attempt to fix zombie creation

Thanks-to: Lev Danilski <8o55kd+1v8xnjsby8b9k <AT> pokemail.net>
Closes: https://bugs.gentoo.org/631316
Package-Manager: Portage-2.3.64, Repoman-2.3.12
Signed-off-by: Lars Wendler <polynomial-c <AT> gentoo.org>

 .../netplug-1.2.9.2-multi-waitpid-sigchld.patch    | 65 +++++++++++++++++++
 sys-apps/netplug/netplug-1.2.9.2-r3.ebuild         | 73 ++++++++++++++++++++++
 2 files changed, 138 insertions(+)

diff --git a/sys-apps/netplug/files/netplug-1.2.9.2-multi-waitpid-sigchld.patch b/sys-apps/netplug/files/netplug-1.2.9.2-multi-waitpid-sigchld.patch
new file mode 100644
index 00000000000..06e645c1dee
--- /dev/null
+++ b/sys-apps/netplug/files/netplug-1.2.9.2-multi-waitpid-sigchld.patch
@@ -0,0 +1,65 @@
+# Rework SIGCHLD handler to anticipate multiple children dying while the
+# handler is being executed.
+#
+# Without the patch if multiple SIGCHLD signals are received while the signal
+# handler is being executed, the first will be left in pending state and the
+# extra discarded. Due to the children processing logic in netplugd, the ones
+# which were missed will never be waited, left as zombies.
+#
+# Implementation of the signal handler is following suggested handling in
+# https://www.gnu.org/software/libc/manual/html_node/Merged-Signals.html
+#
+# The patch strives to change only the children wait logic in the signal
+# handler, it doesn't try to enhance write call error handling or the unsafe
+# call to exit/do_log. Also the formatting is left as it was in the original
+# code.
+
+--- a/main.c
++++ b/main.c
+@@ -153,17 +153,29 @@ static int child_handler_pipe[2];
+ static void
+ child_handler(int sig, siginfo_t *info, void *v)
+ {
+-    struct child_exit ce;
+-    int ret;
+-    ssize_t s = 0;
++    int old_errno = errno;
+ 
+     assert(sig == SIGCHLD);
+ 
+-    ce.pid = info->si_pid;
+-    ret = waitpid(info->si_pid, &ce.status, 0);
+-    if (ret == info->si_pid)
++    while (1)
+     {
+-        s = write(child_handler_pipe[1], &ce, sizeof(ce));
++        pid_t pid;
++        int status;
++
++        do
++        {
++            errno = 0;
++            pid = waitpid(WAIT_ANY, &status, WNOHANG);
++        } while (pid <= 0 && errno == EINTR);
++
++        if (pid <= 0)
++        {
++            break;
++        }
++
++        struct child_exit ce = { .pid = pid, .status = status };
++
++        ssize_t s = write(child_handler_pipe[1], &ce, sizeof(ce));
+ 
+ 	if (s == -1)
+ 	{
+@@ -171,6 +183,9 @@ child_handler(int sig, siginfo_t *info, void *v)
+ 	    exit(1);
+ 	}
+     }
++
++    errno = old_errno;
++    return;
+ }
+ 
+ /* Poll the existing interface state, so we can catch any state

diff --git a/sys-apps/netplug/netplug-1.2.9.2-r3.ebuild b/sys-apps/netplug/netplug-1.2.9.2-r3.ebuild
new file mode 100644
index 00000000000..a452c1ad1c3
--- /dev/null
+++ b/sys-apps/netplug/netplug-1.2.9.2-r3.ebuild
@@ -0,0 +1,73 @@
+# Copyright 1999-2019 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+inherit toolchain-funcs
+
+DESCRIPTION="Brings up/down ethernet ports automatically with cable detection"
+HOMEPAGE="https://www.red-bean.com/~bos/"
+SRC_URI="https://www.red-bean.com/~bos/netplug/${P}.tar.bz2"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~amd64 ~arm ~mips ~ppc ~ppc64 ~sparc ~x86"
+IUSE="debug doc"
+
+DEPEND="doc? ( app-text/ghostscript-gpl
+		media-gfx/graphviz )"
+RDEPEND=""
+
+PATCHES=(
+	# Remove nested functions, #116140
+	"${FILESDIR}/${PN}-1.2.9-remove-nest.patch"
+
+	# Ignore wireless events
+	"${FILESDIR}/${PN}-1.2.9-ignore-wireless.patch"
+
+	# Fix DOWNANDOUT problem #599400
+	"${FILESDIR}/${P}-downandout.patch"
+
+	# Wait for multiple children in SIGCHLD handler #631316
+	"${FILESDIR}/${P}-multi-waitpid-sigchld.patch"
+)
+
+src_prepare() {
+	# Remove debug flags from CFLAGS
+	if ! use debug ; then
+		sed -i -e "s/ -ggdb3//" Makefile || die
+	fi
+
+	# Remove -O3 and -Werror from CFLAGS
+	sed -i -e "s/ -O3//" -e "s/ -Werror//" Makefile || die
+
+	default
+}
+
+src_compile() {
+	tc-export CC
+	emake CC="${CC}"
+
+	if use doc ; then
+		emake -C docs/
+	fi
+}
+
+src_install() {
+	into /
+	dosbin netplugd
+	doman man/man8/netplugd.8
+
+	dodir /etc/netplug.d
+	exeinto /etc/netplug.d
+	newexe "${FILESDIR}/netplug-2" netplug
+
+	dodir /etc/netplug
+	echo "eth*" > "${ED}"/etc/netplug/netplugd.conf || die
+
+	dodoc ChangeLog NEWS README TODO
+
+	if use doc; then
+		dodoc docs/state-machine.ps
+	fi
+}


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2019-04-20 23:07 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-04-20 23:07 [gentoo-commits] repo/gentoo:master commit in: sys-apps/netplug/, sys-apps/netplug/files/ Lars Wendler

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox