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: "^D^H^H" in process output on Darwin (Was Re: grep-use-null-device) Date: Sat, 27 Aug 2005 10:30:41 +0900 Organization: Faculty of Science, Chiba University Message-ID: References: NNTP-Posting-Host: main.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 1125106716 20846 80.91.229.2 (27 Aug 2005 01:38:36 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 27 Aug 2005 01:38:36 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Aug 27 03:38:32 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1E8pdw-00079N-Ls for ged-emacs-devel@m.gmane.org; Sat, 27 Aug 2005 03:38:00 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1E8pht-00078m-F4 for ged-emacs-devel@m.gmane.org; Fri, 26 Aug 2005 21:42:05 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1E8phA-00070F-85 for emacs-devel@gnu.org; Fri, 26 Aug 2005 21:41:22 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1E8ph2-0006uC-1s for emacs-devel@gnu.org; Fri, 26 Aug 2005 21:41:12 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1E8ph1-0006sp-NQ for emacs-devel@gnu.org; Fri, 26 Aug 2005 21:41:11 -0400 Original-Received: from [133.82.132.2] (helo=mathmail.math.s.chiba-u.ac.jp) by monty-python.gnu.org with esmtp (Exim 4.34) id 1E8pYY-0005H1-1o for emacs-devel@gnu.org; Fri, 26 Aug 2005 21:32:26 -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 B9BBD2CBF for ; Sat, 27 Aug 2005 10:30:41 +0900 (JST) Original-To: emacs-devel@gnu.org In-Reply-To: User-Agent: Wanderlust/2.14.0 (Africa) SEMI/1.14.6 (Maruoka) FLIM/1.14.6 (Marutamachi) APEL/10.6 Emacs/22.0.50 (sparc-sun-solaris2.8) MULE/5.0 (SAKAKI) 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:42440 Archived-At: >>>>> On Sat, 20 Aug 2005 15:22:41 +0300, Eli Zaretskii said: >> Thanks for posting the URL, though it seems that the web interface >> at lists.gnu.org eats multiple spaces. Here is the Gmane URL for >> the original post from Kevin Rodgers with correct indentation: >> >> http://article.gmane.org/gmane.emacs.devel/33146 >> >> Can someone please install it? > Done. With this change, we sometimes see "^D^H^H" at the head of the output of grep on Darwin/Mac OS X with whichever window systems (^H is actually in one character). It looks as if the tty echo option is not disabled and ^D is echoed back in response to process-send-eof. I think this is because Emacs may send some data before a subprocess completes tty options setup. On Darwin, vfork is defined as fork for the reason mentioned in src/s/darwin.h. /* The following solves the problem that Emacs hangs when evaluating (make-comint "test0" "/nodir/nofile" nil "") when /nodir/nofile does not exist. */ #undef HAVE_WORKING_VFORK #define vfork fork #define DONT_REOPEN_PTY (It actually hangs on Mac OS X 10.1.5 and 10.2.8 if process-connection-type is set to t. On Mac OS X 10.3.9 it seems not to hang. Are there any other problems with vfork on Mac OS X 10.3, which is based on Darwin 7?) Unlike vfork, the parent process may run before the child process executes the code between (v)fork and execve/_exit if fork is used. The current Emacs disables the tty echo option in the child process (for USG systems?) by calling child_setup_tty. The following patch does tty options setup before forking, and it works for me. YAMAMOTO Mitsuharu mituharu@math.s.chiba-u.ac.jp Index: src/process.c =================================================================== RCS file: /cvsroot/emacs/emacs/src/process.c,v retrieving revision 1.463 diff -c -r1.463 process.c *** src/process.c 15 Aug 2005 08:44:53 -0000 1.463 --- src/process.c 27 Aug 2005 01:25:30 -0000 *************** *** 1793,1798 **** --- 1793,1802 ---- #endif if (forkin < 0) report_file_error ("Opening pty", Qnil); + /* In the case that vfork is defined as fork, the parent process + (Emacs) may send some data before the child process completes + tty options setup. So we setup tty before forking. */ + child_setup_tty (forkout); #else forkin = forkout = -1; #endif /* not USG, or USG_SUBTTY_WORKS */