From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 113544 invoked by alias); 17 Nov 2015 04:05:38 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 113535 invoked by uid 89); 17 Nov 2015 04:05:37 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.8 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Tue, 17 Nov 2015 04:05:37 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id DFED0C02C6A7 for ; Tue, 17 Nov 2015 04:05:35 +0000 (UTC) Received: from pinnacle.lan (ovpn-113-161.phx2.redhat.com [10.3.113.161]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tAH45ZVt009762 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA256 bits=256 verify=NO) for ; Mon, 16 Nov 2015 23:05:35 -0500 Date: Tue, 17 Nov 2015 04:05:00 -0000 From: Kevin Buettner To: gdb-patches@sourceware.org Subject: Re: [PATCH] PPC sim: Don't close file descriptors 0, 1, or 2 Message-ID: <20151116210533.058520d2@pinnacle.lan> In-Reply-To: <20151116235317.GF31395@vapier.lan> References: <20151116145807.4aedd84f@pinnacle.lan> <20151116235317.GF31395@vapier.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2015-11/txt/msg00330.txt.bz2 On Mon, 16 Nov 2015 18:53:17 -0500 Mike Frysinger wrote: > On 16 Nov 2015 14:58, Kevin Buettner wrote: > > This occurs because the powerpc simulator closes, on behalf of the > > testcase, the file descriptors associated with stdin, stdout, and > > stderr. GDB still needs these descriptors to communicate with the > > user or, in this case, with the testing framework. > > special casing this logic in the sim looks wrong to me. why > is the testcase itself trying to close stdin/stdout/stderr ? It's not just one test case, but a bunch of them, 229 to be exact. I haven't investigated all of them, but in many (if not all) of them, close() is being called during exit(). This problem arises when GDB runs the testcase to completion. sim/common achieves the same result by placing file descriptors 0, 1, 2, and MAX_CALLBACK_FDS together in a circular fd_buddy list. (See os_init() in sim/common/callback.c.) close() is never called on any of these descriptors due to the fact that they're in a (circular) list of greater than one element. When one of these descriptors (0, 1, or 2) is closed (in os_close()), it is simply removed from the fd_buddy list, with no close() operation actually being performed. Note that when the final one is "closed", it is still on an fd_buddy list with MAX_CALLBACK_FDS - hence it won't be closed either. So sim/common is doing the same thing as my proposed patch for ppc; sim/common is just using a more elegant mechanism to avoid calling close() on these three file descriptors. Kevin