From huntting@glarp.com  Sat Jul 14 15:33:18 2007
Return-Path: <huntting@glarp.com>
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id 56DF316A400
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 14 Jul 2007 15:33:18 +0000 (UTC)
	(envelope-from huntting@glarp.com)
Received: from refuge.cryptolect.com (refuge.cryptolect.com [63.231.80.17])
	by mx1.freebsd.org (Postfix) with ESMTP id 1E40013C428
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 14 Jul 2007 15:33:18 +0000 (UTC)
	(envelope-from huntting@glarp.com)
Received: from antediluvian.glarp.com (71-218-61-52.hlrn.qwest.net [71.218.61.52])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by refuge.cryptolect.com (Postfix) with ESMTP id 119165085D
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 14 Jul 2007 09:10:11 -0600 (MDT)
Received: from hunkular.glarp.com (hunkular.glarp.com [10.0.0.251])
	by antediluvian.glarp.com (8.14.0/8.13.6) with ESMTP id l6EFA8Ij041254
	(version=TLSv1/SSLv3 cipher=DHE-DSS-AES256-SHA bits=256 verify=NOT)
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 14 Jul 2007 09:10:09 -0600 (MDT)
	(envelope-from huntting@hunkular.glarp.com)
Received: from hunkular.glarp.com (localhost [127.0.0.1])
	by hunkular.glarp.com (8.13.8/8.13.8) with ESMTP id l6EFA73s013553
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 14 Jul 2007 09:10:08 -0600 (MDT)
	(envelope-from huntting@hunkular.glarp.com)
Received: (from huntting@localhost)
	by hunkular.glarp.com (8.13.8/8.13.8/Submit) id l6EFA7FF013465;
	Sat, 14 Jul 2007 09:10:07 -0600 (MDT)
	(envelope-from huntting)
Message-Id: <200707141510.l6EFA7FF013465@hunkular.glarp.com>
Date: Sat, 14 Jul 2007 09:10:07 -0600 (MDT)
From: Brad Huntting <huntting@glarp.com>
Reply-To: Brad Huntting <huntting@glarp.com>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: Portupgrade children have numerous bogus open files.
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         114585
>Category:       ports
>Synopsis:       ports-mgmt/portupgrade children have numerous bogus open files.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    sem
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Jul 14 15:40:02 GMT 2007
>Closed-Date:    Tue Jun 17 10:38:39 UTC 2008
>Last-Modified:  Tue Jun 17 10:38:39 UTC 2008
>Originator:     Brad Huntting
>Release:        FreeBSD 6.2-RELEASE i386
>Organization:
(minimal)
>Environment:
System: FreeBSD hunkular.glarp.com 6.2-RELEASE FreeBSD 6.2-RELEASE #0: Sun Apr 22 23:45:09 MDT 2007 root@hunkular.glarp.com:/usr/src/sys/i386/compile/HUNKULAR i386


>Description:
	Child processes of portupgrade-devel-2.3.0_5 appear to have
	many open file descriptors (>50 in some cases) apprently
	inherited from portupgrade.

	Portupgrade should probably either set the close on exec
	(FD_CLOEXEC) flag when opening files like +CONTENT, or
	explicitly close all non-essential file descriptors after
	fork and before exec.

>How-To-Repeat:
	Upgrade a port with many dependencies.  While it's running,
	run 'fstat' in another window.  Observe the unnaturally
	large number of open file descriptors for processes like
	'make' and 'sh'.

>Fix:

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-ports-bugs->sem 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Sat Jul 14 17:24:19 UTC 2007 
Responsible-Changed-Why:  
Over to maintainer. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=114585 

From: Sergey Matveychuk <sem@FreeBSD.org>
To: bug-followup@FreeBSD.org,  huntting@glarp.com
Cc:  
Subject: Re: ports/114585: ports-mgmt/Portupgrade children have numerous bogus
 open files.
Date: Thu, 19 Jul 2007 13:11:41 +0400

 I don't understand, what do you meant here:
 "explicitly close all non-essential file descriptors after
 fork and before exec."
 
 portupgrade use system() function to run processes. How can I close 
 descriptions after fork and before exec?
 
 And I think I need some examples how to use FD_CLOEXEC too. I've never 
 uses it before.
 -- 
 Dixi.
 Sem.

From: Brad Huntting <huntting@glarp.com>
To: Sergey Matveychuk <sem@FreeBSD.org>
Cc: bug-followup@FreeBSD.org, huntting@glarp.com
Subject: Re: ports/114585: ports-mgmt/Portupgrade children have numerous bogus open files. 
Date: Thu, 19 Jul 2007 09:13:19 -0600

 > I don't understand, what do you meant here:
 > "explicitly close all non-essential file descriptors after
 > fork and before exec."
 
 > portupgrade use system() function to run processes. How can I close 
 > descriptions after fork and before exec?
 
 Yea, that option wouldnt work with system();  better to just use
 close-on-exec.
 
 > And I think I need some examples how to use FD_CLOEXEC too. I've never 
 > uses it before.
 
 Well, in C it's pretty straight forward:
 
 	#include <fcntl.h>
 	/*...*/
 	fcntl(fd, F_SETFD, FD_CLOEXEC)
 
 will set the close-on-exec flag for the file descriptor fd.  This
 ensures that the file descriptor will not be inherited by child
 processes.  You can set the close-on-exec flag anytime.  Typically
 it's done right after the file is open()ed.  Since there's nothing
 constructive to be done if the call fails, I personally dont see
 any point in checking the return value from fcntl().  See fcntl(2)
 details.
 
 I'm not familiar with ruby, but a quick google search suggests there
 is a module for calling fcntl() which is documented in
 
 	http://www.ruby-doc.org/stdlib/libdoc/fcntl/rdoc/index.html
 
 
 brad
State-Changed-From-To: open->closed 
State-Changed-By: sem 
State-Changed-When: Tue Jun 17 10:38:39 UTC 2008 
State-Changed-Why:  
Looks like the bug is fixed in HEAD. Wait for 2.4.4 in ports. Thanks. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=114585 
>Unformatted:
