From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 55384 invoked by alias); 18 Jul 2019 20:53:42 -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 55376 invoked by uid 89); 18 Jul 2019 20:53:42 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=HX-Google-Smtp-Source:APXvYqx7, closes, day X-HELO: mail-wm1-f65.google.com Received: from mail-wm1-f65.google.com (HELO mail-wm1-f65.google.com) (209.85.128.65) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 18 Jul 2019 20:53:41 +0000 Received: by mail-wm1-f65.google.com with SMTP id x15so26838945wmj.3 for ; Thu, 18 Jul 2019 13:53:40 -0700 (PDT) Return-Path: Received: from ?IPv6:2001:8a0:f913:f700:56ee:75ff:fe8d:232b? ([2001:8a0:f913:f700:56ee:75ff:fe8d:232b]) by smtp.gmail.com with ESMTPSA id i6sm20264034wrv.47.2019.07.18.13.53.38 (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Thu, 18 Jul 2019 13:53:38 -0700 (PDT) Subject: Re: [PATCH] Fix new-ui tty stream leak To: Simon Marchi , gdb-patches@sourceware.org References: <20190718184124.21907-1-palves@redhat.com> From: Pedro Alves Message-ID: <2378ac9e-e890-7aff-3b13-a146f89ffecd@redhat.com> Date: Thu, 18 Jul 2019 20:53:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2019-07/txt/msg00443.txt.bz2 On 7/18/19 9:09 PM, Simon Marchi wrote: > On 2019-07-18 2:41 p.m., Pedro Alves wrote: >> I noticed that we never close the stream opened by new-ui. >> >> This fixes it, by adding a new struct ui ctor that takes ownership of >> the passed-in stream. > > Hi Pedro, > > If I am not mistaken, we never delete the UIs themselves either, so it won't > make a difference today, is that right? They just live until the end of the > GDB process. We actually delete them if the tty closes. See stdin_event_handler. E.g., spawn an instance of KDE's console that just runs "tty" to print the terminal device: $ konsole --hold -e tty& Run a new-ui on that terminal: $ gdb -ex "new-ui console /dev/pts/36" ... New UI allocated Now close the konsole window, and back in the main console, GDB prints: Error detected on fd 13 > Still, I think this patch is fine, in that it makes things right in case we > decide to make it possible to close an existing UI some day. Some day is here. :-) Thanks, Pedro Alves