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: Mon, 27 May 2013 10:36:48 -0700 Organization: UCLA Computer Science Department Message-ID: <51A399B0.7070203@cs.ucla.edu> References: <87ppwevddb.fsf@web.de> <51A24870.8020909@cs.ucla.edu> <87fvx93818.fsf@web.de> <51A2B88F.1090404@cs.ucla.edu> <1369658780.23869.57.camel@localhost> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1369676292 5320 80.91.229.3 (27 May 2013 17:38:12 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 27 May 2013 17:38:12 +0000 (UTC) Cc: Michael Heerdegen , 14474@debbugs.gnu.org To: Colin Walters Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon May 27 19:38:12 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 1Uh1N5-0002tt-VU for geb-bug-gnu-emacs@m.gmane.org; Mon, 27 May 2013 19:38:12 +0200 Original-Received: from localhost ([::1]:56143 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uh1N5-0004y1-Js for geb-bug-gnu-emacs@m.gmane.org; Mon, 27 May 2013 13:38:11 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:51898) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uh1Mt-0004xA-CJ for bug-gnu-emacs@gnu.org; Mon, 27 May 2013 13:38:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uh1Mj-00064v-V8 for bug-gnu-emacs@gnu.org; Mon, 27 May 2013 13:37:59 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:48366) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uh1Mj-00064F-Rg for bug-gnu-emacs@gnu.org; Mon, 27 May 2013 13:37:49 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1Uh1Nu-0002AI-M8 for bug-gnu-emacs@gnu.org; Mon, 27 May 2013 13:39:02 -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 17:39:02 +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.13696762978239 (code B ref 14474); Mon, 27 May 2013 17:39:02 +0000 Original-Received: (at 14474) by debbugs.gnu.org; 27 May 2013 17:38:17 +0000 Original-Received: from localhost ([127.0.0.1]:36724 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Uh1NA-00028q-Ht for submit@debbugs.gnu.org; Mon, 27 May 2013 13:38:16 -0400 Original-Received: from smtp.cs.ucla.edu ([131.179.128.62]:50697) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Uh1N7-00028Y-4i for 14474@debbugs.gnu.org; Mon, 27 May 2013 13:38:15 -0400 Original-Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 8236939E8116; Mon, 27 May 2013 10:36:53 -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 8QWghTfsaAXj; Mon, 27 May 2013 10:36:52 -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 69B8839E8113; Mon, 27 May 2013 10:36:52 -0700 (PDT) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130510 Thunderbird/17.0.6 In-Reply-To: <1369658780.23869.57.camel@localhost> 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:74602 Archived-At: [The context is http://bugs.gnu.org/14474 ] On 05/27/2013 05:46 AM, Colin Walters wrote: > Basically it's going to be very hard over time to avoid codepaths > in the GTK+ stack that don't call g_spawn_*() indirectly, thus > installing a SIGCHLD handler Thanks. In that case, shouldn't the glib documentation be changed to warn application developers not to install a SIGCHLD handler as well? Currently it warns them only to not call waitpid(-1, ...). Are application developers allowed to temporarily mask SIGCHLD? Emacs does that a lot. >> One possibility is to see if we can get Emacs to use >> > glib's child watcher. > That'd be best obviously. I suspect so too, but it requires more expertise in glib than I have (which is, basically, nothing). If I understand things correctly, if Emacs is using Gtk it should * never call sigaction (SIGCHLD, ...) or signal (SIGCHLD, ...) or waitpid (-1, ...). E.g., remove the current call to sigaction (SIGCHLD, ...), in src/process.c's init_process_emacs. =20 * Whenever Emacs creates a child process, use the following pattern: block SIGCHLD; pid =3D vfork (); if (pid > 0) { record pid in Emacs's process table, as location 'loc'; record in *loc that glib is watching this pid; g_child_watch_add (pid, watcher, loc); } unblock SIGCHLD; * never call waitpid (pid, ...) if PID is recorded in Emacs's process table as something that glib is watching. * Add a glue function ("watcher", above) that does something like this: void watcher (GPid pid, gint status, gpointer loc) { block SIGCHLD record that PID exited with status STATUS, by modifying *LOC, sort of like's what currently done in handle_child_signal; if (input_available_clear_time) *input_available_clear_time =3D make_emacs_time (0, 0); unblock SIGCHLD } But this sounds incomplete. No doubt there's something about the main loop, or setting up the watchers, that I don't know about. E.g., how does one remove the watcher once it has fired and told us that the process has exited? I'll CC: this to Jan Dj=C3=A4rv, who knows about gtk, to see if he can help.