From owner-freebsd-ports-bugs@FreeBSD.ORG Wed Aug 29 09:30:06 2012 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 DDA01106566B for ; Wed, 29 Aug 2012 09:30:06 +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 AEB838FC0C for ; Wed, 29 Aug 2012 09:30:06 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id q7T9U6Fe041175 for ; Wed, 29 Aug 2012 09:30:06 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id q7T9U6Sm041172; Wed, 29 Aug 2012 09:30:06 GMT (envelope-from gnats) Date: Wed, 29 Aug 2012 09:30:06 GMT Message-Id: <201208290930.q7T9U6Sm041172@freefall.freebsd.org> To: freebsd-ports-bugs@FreeBSD.org From: Stefan Esser Cc: Subject: Re: ports/171155: PKGNG fails to deinstall large ports X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Stefan Esser List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Aug 2012 09:30:07 -0000 The following reply was made to PR ports/171155; it has been noted by GNATS. From: Stefan Esser To: bug-followup@FreeBSD.org Cc: se@FreeBSD.org, bapt@FreeBSD.org Subject: Re: ports/171155: PKGNG fails to deinstall large ports Date: Wed, 29 Aug 2012 11:22:50 +0200 This is a multi-part message in MIME format. --------------050402090505090709060608 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit The attached patch seems to fix the problem reported in the PR. It allows the math/lapack port to be deinstalled. The error checking may need review since my intent was to show that the popen() approach suggested in the PR is viable. Regards, STefan --------------050402090505090709060608 Content-Type: text/plain; charset=windows-1252; name="patch-libpkg_scripts.c" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="patch-libpkg_scripts.c" --- libpkg/scripts.c~ 2012-08-16 10:24:31.000000000 +0200 +++ libpkg/scripts.c 2012-08-29 10:37:08.300667589 +0200 @@ -45,10 +45,9 @@ { struct sbuf * const script_cmd = sbuf_new_auto(); size_t i, j; - int error, pstat; - pid_t pid; + int error; const char *name, *prefix, *version; - const char *argv[4]; + FILE *shell; struct { const char * const arg; @@ -66,10 +65,6 @@ pkg_get(pkg, PKG_PREFIX, &prefix, PKG_NAME, &name, PKG_VERSION, &version); - argv[0] = "sh"; - argv[1] = "-c"; - argv[3] = NULL; - for (i = 0; i < sizeof(map) / sizeof(map[0]); i++) { if (map[i].a == type) break; @@ -96,11 +91,14 @@ sbuf_cat(script_cmd, "\n"); sbuf_cat(script_cmd, pkg_script_get(pkg, j)); sbuf_finish(script_cmd); - argv[2] = sbuf_get(script_cmd); - - if ((error = posix_spawn(&pid, _PATH_BSHELL, NULL, - NULL, __DECONST(char **, argv), - environ)) != 0) { + shell = popen(_PATH_BSHELL, "w"); + if (shell == NULL) { + error = EPIPE; + } else { + if (fputs(sbuf_get(script_cmd), shell) == EOF) + error = EPIPE; + } + if (error) { errno = error; pkg_emit_errno("Cannot run script", map[i].arg); @@ -109,13 +107,7 @@ } unsetenv("PKG_PREFIX"); - - while (waitpid(pid, &pstat, 0) == -1) { - if (errno != EINTR) - return (EPKG_FATAL); - } - - if (WEXITSTATUS(pstat) != 0) { + if (pclose(shell) != 0) { pkg_emit_error("%s script failed", map[i].arg); return (EPKG_FATAL); } --------------050402090505090709060608--