From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Brent Goodrick" Newsgroups: gmane.emacs.bugs Subject: bug#1112: 23.0.60; Child process not cleaned up properly Date: Wed, 8 Oct 2008 07:53:55 -0700 Message-ID: References: <87abdgmcn6.fsf@gmx.de> Reply-To: Brent Goodrick , 1112@emacsbugs.donarmstrong.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1223479975 17805 80.91.229.12 (8 Oct 2008 15:32:55 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 8 Oct 2008 15:32:55 +0000 (UTC) Cc: 1112@emacsbugs.donarmstrong.com To: "Sven Joachim" Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Oct 08 17:33:42 2008 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Knagx-0000XE-1l for geb-bug-gnu-emacs@m.gmane.org; Wed, 08 Oct 2008 17:11:11 +0200 Original-Received: from localhost ([127.0.0.1]:39834 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Knaft-00009h-0l for geb-bug-gnu-emacs@m.gmane.org; Wed, 08 Oct 2008 11:10:05 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Knafp-00007W-Lj for bug-gnu-emacs@gnu.org; Wed, 08 Oct 2008 11:10:01 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Knafo-00006g-S2 for bug-gnu-emacs@gnu.org; Wed, 08 Oct 2008 11:10:01 -0400 Original-Received: from [199.232.76.173] (port=54972 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Knafo-00006K-Kw for bug-gnu-emacs@gnu.org; Wed, 08 Oct 2008 11:10:00 -0400 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:39093) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Knafo-0002hI-CY for bug-gnu-emacs@gnu.org; Wed, 08 Oct 2008 11:10:00 -0400 Original-Received: from rzlab.ucr.edu (rzlab.ucr.edu [127.0.0.1]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id m98F9vul029759; Wed, 8 Oct 2008 08:09:57 -0700 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.13.8/8.13.8/Submit) id m98F03K1026621; Wed, 8 Oct 2008 08:00:03 -0700 X-Loop: don@donarmstrong.com Resent-From: "Brent Goodrick" Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs Resent-Date: Wed, 08 Oct 2008 15:00:03 +0000 Resent-Message-ID: Resent-Sender: don@donarmstrong.com X-Emacs-PR-Message: report 1112 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Original-Received: via spool by 1112-submit@emacsbugs.donarmstrong.com id=B1112.122347764925390 (code B ref 1112); Wed, 08 Oct 2008 15:00:03 +0000 Original-Received: (at 1112) by emacsbugs.donarmstrong.com; 8 Oct 2008 14:54:09 +0000 Original-Received: from mail-gx0-f19.google.com (mail-gx0-f19.google.com [209.85.217.19]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id m98Es1Jr025384 for <1112@emacsbugs.donarmstrong.com>; Wed, 8 Oct 2008 07:54:02 -0700 Original-Received: by gxk12 with SMTP id 12so8365463gxk.1 for <1112@emacsbugs.donarmstrong.com>; Wed, 08 Oct 2008 07:53:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:cc:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=awT8B7MKj8qMQ8rsr2ikL9Y6wK0ShtqiHayzG10WLes=; b=bUEuVPIc5/p3eHsR745iASfLEaD0+W+GRXrdOYcqvmhOQZMsfzgMGP6KxAlbqY5c3e wlPHdk4mztEwPU32yaYu/SQH27h64oJvTMwgwmyAAJ+yBEdfh3PTwe7b6XzLc0inTtjW fkOEtl/kDyDaEH7jS6w7jt0s+dlvxRRTOaNIo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=XD7MEb523t6MLn2sz9/6wR8XQY2QIbW+uowvdAHe4MhGthFbn8VYu+TVyD6+QpsKdv M91X22OiMRjr3t2NPpi4g0KCm3pNVN9+vzaMWu66CSCnoZFSE6iW5swqONKGyuwzLPg1 +PAKxIpC03N1p9YD77L2Ubk0NQDE5SjKTVy3Q= Original-Received: by 10.90.98.12 with SMTP id v12mr9367169agb.23.1223477635640; Wed, 08 Oct 2008 07:53:55 -0700 (PDT) Original-Received: by 10.90.50.18 with HTTP; Wed, 8 Oct 2008 07:53:55 -0700 (PDT) In-Reply-To: <87abdgmcn6.fsf@gmx.de> Content-Disposition: inline X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) Resent-Date: Wed, 08 Oct 2008 11:10:01 -0400 X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:21273 Archived-At: Hi Sven, I agree about the part about the process permissions: Emacs definitely cannot kill the process because it is a sudo process. However, if Emacs fails to kill the process, Emacs should emit a warning message as to the reason why the process could not be killed (e.g., "process id 12345 could not be killed: operation not permitted"). This would be appropriate in the case where the user kills the process buffer on a long running process (a process that is not attempting to read from standard input as this one is; see next paragraph). This warning is appropriate because otherwise, the user thinks that the process died on its own and will have to discover the hard way via some degree of head-scratching that the process could not be killed. There is more to this problem than process permissions. The process has opened up standard input for the Y/N prompt. When I run compilation mode on some process, I expect no user prompts (if I wanted to handle prompts,I would execute it under the ever so handy shell mode). But, when that process does read standard input for prompting, I want that process to exit immediately (and most well behaved apps do this these days, with the exception of Bourne shell scripts using the "read" operator which doesn't behave correctly IMO). As a proof of concept, when I type "sudo apt-get some_package < /dev/null" into a M-x compile prompt, I see reasonable behavior: After this operation, 27.5MB of additional disk space will be used. Do you want to continue [Y/n]? Abort. Compilation exited abnormally with code 1 at Wed Oct 8 07:18:54 So, is there any harm in having compilation mode close standard input when it spawns any and all processes (perhaps only under the direction of a customizable and properly documented defvar variable so as to avoid backlash from users expecting the existing behavior)? If so, this would fix this issue in the majority of cases. Actually, this closing of standard input should be an option on the lowest level Elisp command that compile uses to start processes, if it is not already exposed as such: I imagine that having to hack this into the compile mode Elisp code itself would be problematic given that the "< /dev/null" construct would have to vary quite a bit on the two axes of type of shell and execution platform. Thanks, Brent On Tue, Oct 7, 2008 at 12:24 PM, Sven Joachim wrote: > > On 2008-10-07 17:15 +0200, Brent Goodrick wrote: > > > 1. M-x compile > > 2. Enter in: sudo apt-get install gimp-help-en > > 3. See the apt-get prompt: > > Reading package lists... 0% > > > > The following extra packages will be installed: > > gimp-help-common > > The following NEW packages will be installed: > > gimp-help-common gimp-help-en > > 0 upgraded, 2 newly installed, 0 to remove and 1 not upgraded. > > Need to get 15.9MB of archives. > > After this operation, 27.5MB of additional disk space will be used. > > Do you want to continue [Y/n]? > > 4. Kill the buffer, and expect the underlying process to die, just > > like you would have if you had typed the above command in a shell > > buffer. > > Won't work for processes run under sudo, see below. > > > 5. Open up a shell, and type ps to see that the apt-get process still > > exists > > 6. Go through step 1 again and notice now that a lock is being > > reported by the second apt-get session because the first process > > was not properly torn down by the act of killing the previous > > compilation buffer. > > > > My assessment: The shell mode somehow works differently than the > > compilation mode since the compilation mode does not allow user > > input. Fair enough, but the two modes should work the same in terms of > > tearing down the two processes if the buffers are killed, and should > > not ever leave dormant child processes. > > The real problem is that sudo is suid root and thus the compilation > process runs with superuser rights. Emacs is simply lacking the > privileges to kill it. > > You can try something similar in your shell: > > ,---- > | % sudo sleep 1000 & > | [1] 2186 > | % kill %1 > | kill: kill %1 failed: operation not permitted > | % sudo kill $(pidof sleep) > | [1] + 2186 terminated sudo sleep 1000 > | % > `---- > > Sven