From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: YAMAMOTO Mitsuharu Newsgroups: gmane.emacs.devel Subject: Re: busyloop in sigchld_handler Date: Mon, 26 Mar 2007 10:47:41 +0900 Organization: Faculty of Science, Chiba University Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII X-Trace: sea.gmane.org 1174873685 28694 80.91.229.12 (26 Mar 2007 01:48:05 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 26 Mar 2007 01:48:05 +0000 (UTC) Cc: emacs-devel@gnu.org To: sds@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Mar 26 03:47:57 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1HVeJR-0006du-4B for ged-emacs-devel@m.gmane.org; Mon, 26 Mar 2007 03:47:57 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HVeLc-0008Oe-HZ for ged-emacs-devel@m.gmane.org; Sun, 25 Mar 2007 20:50:12 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HVeLZ-0008Mb-8v for emacs-devel@gnu.org; Sun, 25 Mar 2007 21:50:09 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HVeLW-0008Ln-U0 for emacs-devel@gnu.org; Sun, 25 Mar 2007 21:50:08 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HVeLW-0008Lk-Na for emacs-devel@gnu.org; Sun, 25 Mar 2007 20:50:06 -0500 Original-Received: from ntp.math.s.chiba-u.ac.jp ([133.82.132.2] helo=mathmail.math.s.chiba-u.ac.jp) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1HVeJG-0000Ge-J5; Sun, 25 Mar 2007 21:47:47 -0400 Original-Received: from church.math.s.chiba-u.ac.jp (church [133.82.132.36]) by mathmail.math.s.chiba-u.ac.jp (Postfix) with ESMTP id 0DA542C49; Mon, 26 Mar 2007 10:47:42 +0900 (JST) In-Reply-To: User-Agent: Wanderlust/2.14.0 (Africa) SEMI/1.14.6 (Maruoka) FLIM/1.14.8 (=?ISO-8859-4?Q?Shij=F2?=) APEL/10.6 Emacs/22.0.96 (sparc-sun-solaris2.8) MULE/5.0 (SAKAKI) X-detected-kernel: NetBSD 3.0 (DF) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:68556 Archived-At: The following change (without a ChangeLog entry) made operations using subprocesses really sluggish on Mac OS X. Is it possible to restrict the workaround to the relevant platforms? YAMAMOTO Mitsuharu mituharu@math.s.chiba-u.ac.jp =================================================================== RCS file: /sources/emacs/emacs/src/process.c,v retrieving revision 1.505 retrieving revision 1.506 diff -c -r1.505 -r1.506 *** emacs/src/process.c 2007/03/20 08:51:03 1.505 --- emacs/src/process.c 2007/03/25 03:03:40 1.506 *************** *** 6501,6517 **** #define WUNTRACED 0 #endif /* no WUNTRACED */ /* Keep trying to get a status until we get a definitive result. */ ! while (1) ! { errno = 0; pid = wait3 (&w, WNOHANG | WUNTRACED, 0); - if (! (pid < 0 && errno == EINTR)) - break; - /* Avoid a busyloop: wait3 is a system call, so we do not want - to prevent the kernel from actually sending SIGCHLD to emacs - by asking for it all the time. */ - sleep (1); } if (pid <= 0) { --- 6501,6517 ---- #define WUNTRACED 0 #endif /* no WUNTRACED */ /* Keep trying to get a status until we get a definitive result. */ ! do ! { ! /* For some reason, this sleep() prevents Emacs from sending ! loadavg to 5-8(!) for ~10 seconds. ! See http://thread.gmane.org/gmane.emacs.devel/67722 or ! http://www.google.com/search?q=busyloop+in+sigchld_handler */ ! sleep (1); errno = 0; pid = wait3 (&w, WNOHANG | WUNTRACED, 0); } + while (pid < 0 && errno == EINTR); if (pid <= 0) {