diff options
author | lioux <lioux@FreeBSD.org> | 2002-11-19 02:12:55 +0000 |
---|---|---|
committer | lioux <lioux@FreeBSD.org> | 2002-11-19 02:12:55 +0000 |
commit | 2e8218e71d773f6762885b49c85d8199d8c2abb1 (patch) | |
tree | 0bd1cdb66dfd1e77dfa51a45b107d51c693f26be /net/dctc-gui | |
parent | f9f382538c57eaf78ade3a7f9eb074ef795149c3 (diff) | |
download | FreeBSD-ports-2e8218e71d773f6762885b49c85d8199d8c2abb1.zip FreeBSD-ports-2e8218e71d773f6762885b49c85d8199d8c2abb1.tar.gz |
Add SIGCHLD signal(3) handling to prevent zombie processes
Diffstat (limited to 'net/dctc-gui')
-rw-r--r-- | net/dctc-gui/Makefile | 15 | ||||
-rw-r--r-- | net/dctc-gui/files/patch-src::main.c | 36 | ||||
-rw-r--r-- | net/dctc-gui/files/sig_chld.c | 53 |
3 files changed, 104 insertions, 0 deletions
diff --git a/net/dctc-gui/Makefile b/net/dctc-gui/Makefile index fbb5de0..3a1e373 100644 --- a/net/dctc-gui/Makefile +++ b/net/dctc-gui/Makefile @@ -7,6 +7,7 @@ PORTNAME= dctc PORTVERSION= 0.65 +PORTREVISION= 1 CATEGORIES= net gnome MASTER_SITES= http://unixpages.org/distfiles/ \ http://ac2i.tzo.com/dctc/ @@ -31,8 +32,15 @@ CONFIGURE_ARGS= --with-gnome=${X11BASE} \ --enable-manual-db-detect \ --with-libiconv-prefix=${LOCALBASE} +ADDITIONAL_SRCS= sig_chld.c +# DOC_FILES= COPYING ChangeLog README TODO +post-extract: +.for file in ${ADDITIONAL_SRCS} + @${CP} ${FILESDIR}/${file} ${WRKSRC}/src +.endfor + post-patch: @${FIND} ${WRKSRC} -type f | ${XARGS} -n 10 -x ${REINPLACE_CMD} -E -e \ 's|ldb-4.0|ldb4|; \ @@ -52,6 +60,13 @@ post-patch: @${FIND} ${WRKSRC} -type f \ -name "*.bak" \ | ${XARGS} -n 10 -x ${RM} +# add sigchld handler +.for file in ${ADDITIONAL_SRCS} + @${REINPLACE_CMD} -E -e \ + 's|^(dc_gui_SOURCES.+)$$|\1 ${file}|; \ + s|^(dc_gui_OBJECTS[^\\]+)(\\*)$$|\1 ${file:S/.c$/.o/} \2|' \ + ${WRKSRC}/src/Makefile.in +.endfor post-configure: @${ECHO_CMD} '#ifndef MSG_NOSIGNAL' >> ${CONFIGURE_WRKSRC}/config.h diff --git a/net/dctc-gui/files/patch-src::main.c b/net/dctc-gui/files/patch-src::main.c new file mode 100644 index 0000000..f530cca --- /dev/null +++ b/net/dctc-gui/files/patch-src::main.c @@ -0,0 +1,36 @@ +--- src/main.c.orig Mon Nov 18 23:53:50 2002 ++++ src/main.c Mon Nov 18 23:55:01 2002 +@@ -43,6 +43,9 @@ + GtkWidget *done_popup=NULL; + GtkWidget *fav_popup=NULL; + ++/* sigchld handling */ ++extern void sig_chld(int); ++ + /* this string is "$HOME/.dctc" */ + GString *dctc_main_dir=NULL; + +@@ -289,11 +292,9 @@ + sigset_t set; + + /* ignore SIGPIPE */ +- /* ignore SIGCHLD */ + /* ignore SIGHUP */ + sigemptyset(&set); + sigaddset(&set,SIGPIPE); +- sigaddset(&set,SIGCHLD); + sigaddset(&set,SIGHUP); + act.sa_handler=SIG_IGN; + act.sa_mask=set; +@@ -301,8 +302,10 @@ + + sigprocmask(SIG_UNBLOCK,&set,NULL); + sigaction(SIGPIPE,&act,NULL); +- sigaction(SIGCHLD,&act,NULL); + sigaction(SIGHUP,&act,NULL); ++ ++ /* handle SIGCHLD */ ++ signal(SIGCHLD, sig_chld); /* Prevents zombies */ + } + + static void start_dctc_client_from_huburl(char *dchub_url,char *profile) diff --git a/net/dctc-gui/files/sig_chld.c b/net/dctc-gui/files/sig_chld.c new file mode 100644 index 0000000..74b4a4a --- /dev/null +++ b/net/dctc-gui/files/sig_chld.c @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2000, 2001, 2002 + * Mario Sergio Fujikawa Ferreira <lioux@FreeBSD.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD + */ + +#include <sys/types.h> +#include <sys/wait.h> +/* +#include <sys/time.h> +#include <sys/resource.h> +*/ + +/* + * SIGCHLD handler + * + * Let's take care of our children. + * Otherwise, they may get involved with bad ppl + * and become zombies. + */ +void +sig_chld(int signo) +{ + pid_t pid; + int stat; + + while ( (pid = waitpid(-1, &stat, WNOHANG)) > 0); + + return; +} |