From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.bugs Subject: bug#14474: 24.3.50; Zombie subprocesses (again) Date: Sun, 26 May 2013 18:36:15 -0700 Organization: UCLA Computer Science Department Message-ID: <51A2B88F.1090404@cs.ucla.edu> References: <87ppwevddb.fsf@web.de> <51A24870.8020909@cs.ucla.edu> <87fvx93818.fsf@web.de> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1369618634 24944 80.91.229.3 (27 May 2013 01:37:14 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 27 May 2013 01:37:14 +0000 (UTC) Cc: 14474@debbugs.gnu.org, Colin Walters To: Michael Heerdegen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon May 27 03:37:14 2013 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UgmN4-0007tA-0k for geb-bug-gnu-emacs@m.gmane.org; Mon, 27 May 2013 03:37:10 +0200 Original-Received: from localhost ([::1]:47664 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UgmN3-0006iK-Lt for geb-bug-gnu-emacs@m.gmane.org; Sun, 26 May 2013 21:37:09 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:57045) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UgmMw-0006iB-J4 for bug-gnu-emacs@gnu.org; Sun, 26 May 2013 21:37:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UgmMm-0004Kl-QT for bug-gnu-emacs@gnu.org; Sun, 26 May 2013 21:37:02 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:47552) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UgmMm-0004Kd-MW for bug-gnu-emacs@gnu.org; Sun, 26 May 2013 21:36:52 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1UgmNt-0005wk-LE for bug-gnu-emacs@gnu.org; Sun, 26 May 2013 21:38:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Paul Eggert Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 27 May 2013 01:38:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 14474 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 14474-submit@debbugs.gnu.org id=B14474.136961865722808 (code B ref 14474); Mon, 27 May 2013 01:38:01 +0000 Original-Received: (at 14474) by debbugs.gnu.org; 27 May 2013 01:37:37 +0000 Original-Received: from localhost ([127.0.0.1]:35910 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UgmNU-0005vk-CW for submit@debbugs.gnu.org; Sun, 26 May 2013 21:37:37 -0400 Original-Received: from smtp.cs.ucla.edu ([131.179.128.62]:50311) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UgmNR-0005vS-Ly for 14474@debbugs.gnu.org; Sun, 26 May 2013 21:37:35 -0400 Original-Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id EC7A1A60001; Sun, 26 May 2013 18:36:17 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Original-Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id C+v8x9vfKYwn; Sun, 26 May 2013 18:36:16 -0700 (PDT) Original-Received: from [192.168.1.9] (pool-71-108-49-126.lsanca.fios.verizon.net [71.108.49.126]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 1B0D939E8113; Sun, 26 May 2013 18:36:16 -0700 (PDT) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130510 Thunderbird/17.0.6 In-Reply-To: <87fvx93818.fsf@web.de> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:74590 Archived-At: [The bug is that a bleeding-edge GTK Emacs loses child processes when it's run via sudo; see .] I think I may have spotted the problem. Glib 2.36.2's glib/gmain.c has a function 'ensure_unix_signal_handler_installed_unlocked' that is run in the dconf worker thread. This function calls sigaction to replace Emacs's SIGCHLD handler with glib's own handler g_unix_signal_handler. Signal handlers are process-wide, so this replacement affects all threads, including the main (Emacs) thread. After that happens, Emacs never sees when its children exit, since g_unix_signal_handler discards Emacs's child-exit notices, and the Emacs function deliver_child_signal is never invoked. The comment for g_child_watch_source_new says that Emacs isn't supposed to invoke waitpid (-1, ...), but that's already the case in the Emacs trunk. Is there another limitation that we didn't know about, a limitation that says Emacs can't have signal handlers either? I'll CC: this to Colin Walters since he seemed to have a good handle on the situation from the glib point of view; see . One possibility is to see if we can get Emacs to use glib's child watcher. But that's a bit of a delicate balance, since Emacs must work even when gtk is absent, and it may need to hand off from its own watcher to glib's watcher, and processes shouldn't get lost during the handoff. I don't offhand know how to do all that. A simpler but hacky workaround is to not use the graphical interface if DBUS_SESSION_BUS_ADDRESS is unset. Something like this: --- src/xterm.c 2013-05-09 14:49:56 +0000 +++ src/xterm.c 2013-05-27 01:32:44 +0000 @@ -9819,6 +9819,14 @@ x_display_ok (const char *display) int dpy_ok = 1; Display *dpy; +#ifdef USE_GTK + if (! egetenv ("DBUS_SESSION_BUS_ADDRESS")) + { + fprintf (stderr, "DBUS_SESSION_BUS_ADDRESS unset, so Gtk is unsafe\n"); + return 0; + } +#endif + dpy = XOpenDisplay (display); if (dpy) XCloseDisplay (dpy);